Skip to content

Commit

Permalink
[SPARK-3708][SQL] Backticks aren't handled correctly is aliases
Browse files Browse the repository at this point in the history
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 apache#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
  • Loading branch information
ravipesala authored and marmbrus committed Nov 11, 2014
1 parent 064750d commit 4c9f3e6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,7 @@ private[hive] object HiveQl {

case Token("TOK_SELEXPR",
e :: Token(alias, Nil) :: Nil) =>
Some(Alias(nodeToExpr(e), alias)())
Some(Alias(nodeToExpr(e), cleanIdentifier(alias))())

/* Hints are ignored */
case Token("TOK_HINTLIST", _) => None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class SQLQuerySuite extends QueryTest {
test("ordering not in agg") {
checkAnswer(
sql("SELECT key FROM src GROUP BY key, value ORDER BY value"),
sql("""
sql( """
SELECT key
FROM (
SELECT key, value
Expand All @@ -58,7 +58,7 @@ class SQLQuerySuite extends QueryTest {
test("test CTAS") {
checkAnswer(sql("CREATE TABLE test_ctas_123 AS SELECT key, value FROM src"), Seq.empty[Row])
checkAnswer(
sql("SELECT key, value FROM test_ctas_123 ORDER BY key"),
sql("SELECT key, value FROM test_ctas_123 ORDER BY key"),
sql("SELECT key, value FROM src ORDER BY key").collect().toSeq)
}

Expand Down

0 comments on commit 4c9f3e6

Please sign in to comment.