Skip to content

Commit 6ab9191

Browse files
author
aokolnychyi
committed
[SPARK-21102][SQL] Handle additional symbols
1 parent 8d820f3 commit 6ab9191

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

sql/core/src/main/scala/org/apache/spark/sql/execution/SparkSqlParser.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,9 +243,10 @@ class SparkSqlAstBuilder(conf: SQLConf) extends AstBuilder(conf) {
243243
unquotedPath != null && !unquotedPath.isEmpty,
244244
"Resource paths cannot be empty in REFRESH statements. Use / to match everything",
245245
ctx)
246+
val forbiddenSymbols = Seq(" ", "\n", "\r", "\t")
246247
validate(
247-
!unquotedPath.contains(' '),
248-
"It is not allowed to use spaces inside unquoted resource paths in REFRESH statements",
248+
!forbiddenSymbols.exists(unquotedPath.contains(_)),
249+
"REFRESH statements cannot contain ' ', '\\n', '\\r', '\\t' inside unquoted resource paths",
249250
ctx)
250251
unquotedPath
251252
}

sql/core/src/test/scala/org/apache/spark/sql/execution/SparkSqlParserSuite.scala

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -75,18 +75,14 @@ class SparkSqlParserSuite extends AnalysisTest {
7575
assertEqual("REFRESH path-with-dash", RefreshResource("path-with-dash"))
7676
assertEqual("REFRESH \'path with space\'", RefreshResource("path with space"))
7777
assertEqual("REFRESH \"path with space 2\"", RefreshResource("path with space 2"))
78-
intercept(
79-
"REFRESH a b",
80-
"It is not allowed to use spaces inside unquoted resource paths in REFRESH statements")
81-
intercept(
82-
"REFRESH @ $a$",
83-
"It is not allowed to use spaces inside unquoted resource paths in REFRESH statements")
84-
intercept(
85-
"REFRESH ",
86-
"Resource paths cannot be empty in REFRESH statements. Use / to match everything")
87-
intercept(
88-
"REFRESH",
89-
"Resource paths cannot be empty in REFRESH statements. Use / to match everything")
78+
intercept("REFRESH a b", "REFRESH statements cannot contain")
79+
intercept("REFRESH a\tb", "REFRESH statements cannot contain")
80+
intercept("REFRESH a\nb", "REFRESH statements cannot contain")
81+
intercept("REFRESH a\rb", "REFRESH statements cannot contain")
82+
intercept("REFRESH a\r\nb", "REFRESH statements cannot contain")
83+
intercept("REFRESH @ $a$", "REFRESH statements cannot contain")
84+
intercept("REFRESH ", "Resource paths cannot be empty in REFRESH statements")
85+
intercept("REFRESH", "Resource paths cannot be empty in REFRESH statements")
9086
}
9187

9288
test("show functions") {

0 commit comments

Comments
 (0)