Skip to content

Commit ecb7194

Browse files
committed
Trimmed the SQL string before parsing special commands
1 parent 6f4ce42 commit ecb7194

File tree

1 file changed

+7
-7
lines changed
  • sql/hive/src/main/scala/org/apache/spark/sql/hive

1 file changed

+7
-7
lines changed

sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveQl.scala

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -218,19 +218,19 @@ private[hive] object HiveQl {
218218
case Array(key, value) => // "set key=value"
219219
SetCommand(Some(key), Some(value))
220220
}
221-
} else if (sql.toLowerCase.startsWith("cache table")) {
221+
} else if (sql.trim.toLowerCase.startsWith("cache table")) {
222222
CacheCommand(sql.drop(12).trim, true)
223-
} else if (sql.toLowerCase.startsWith("uncache table")) {
223+
} else if (sql.trim.toLowerCase.startsWith("uncache table")) {
224224
CacheCommand(sql.drop(14).trim, false)
225-
} else if (sql.toLowerCase.startsWith("add jar")) {
225+
} else if (sql.trim.toLowerCase.startsWith("add jar")) {
226226
AddJar(sql.drop(8))
227-
} else if (sql.toLowerCase.startsWith("add file")) {
227+
} else if (sql.trim.toLowerCase.startsWith("add file")) {
228228
AddFile(sql.drop(9))
229-
} else if (sql.startsWith("dfs")) {
229+
} else if (sql.trim.startsWith("dfs")) {
230230
DfsCommand(sql)
231-
} else if (sql.startsWith("source")) {
231+
} else if (sql.trim.startsWith("source")) {
232232
SourceCommand(sql.split(" ").toSeq match { case Seq("source", filePath) => filePath })
233-
} else if (sql.startsWith("!")) {
233+
} else if (sql.trim.startsWith("!")) {
234234
ShellCommand(sql.drop(1))
235235
} else {
236236
val tree = getAst(sql)

0 commit comments

Comments
 (0)