Skip to content

Commit 4c9f3e6

Browse files
ravipesalamarmbrus
authored andcommitted
[SPARK-3708][SQL] Backticks aren't handled correctly is aliases
The below query gives error sql("SELECT k FROM (SELECT \`key\` AS \`k\` FROM src) a") It gives error because the aliases are not cleaned so it could not be resolved in further processing. Author: ravipesala <[email protected]> Closes #2594 from ravipesala/SPARK-3708 and squashes the following commits: d55db54 [ravipesala] Fixed SPARK-3708 (Backticks aren't handled correctly is aliases) Conflicts: sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/SQLQuerySuite.scala
1 parent 064750d commit 4c9f3e6

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -843,7 +843,7 @@ private[hive] object HiveQl {
843843

844844
case Token("TOK_SELEXPR",
845845
e :: Token(alias, Nil) :: Nil) =>
846-
Some(Alias(nodeToExpr(e), alias)())
846+
Some(Alias(nodeToExpr(e), cleanIdentifier(alias))())
847847

848848
/* Hints are ignored */
849849
case Token("TOK_HINTLIST", _) => None

sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/SQLQuerySuite.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class SQLQuerySuite extends QueryTest {
3939
test("ordering not in agg") {
4040
checkAnswer(
4141
sql("SELECT key FROM src GROUP BY key, value ORDER BY value"),
42-
sql("""
42+
sql( """
4343
SELECT key
4444
FROM (
4545
SELECT key, value
@@ -58,7 +58,7 @@ class SQLQuerySuite extends QueryTest {
5858
test("test CTAS") {
5959
checkAnswer(sql("CREATE TABLE test_ctas_123 AS SELECT key, value FROM src"), Seq.empty[Row])
6060
checkAnswer(
61-
sql("SELECT key, value FROM test_ctas_123 ORDER BY key"),
61+
sql("SELECT key, value FROM test_ctas_123 ORDER BY key"),
6262
sql("SELECT key, value FROM src ORDER BY key").collect().toSeq)
6363
}
6464

0 commit comments

Comments
 (0)