You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by ma...@apache.org on 2014/10/10 03:41:36 UTC
git commit: [SPARK-3834][SQL] Backticks not correctly handled in
subquery aliases
Repository: spark
Updated Branches:
refs/heads/master 421382d0e -> 6f98902a3
[SPARK-3834][SQL] Backticks not correctly handled in subquery aliases
The queries like SELECT a.key FROM (SELECT key FROM src) \`a\` does not work as backticks in subquery aliases are not handled properly. This PR fixes that.
Author : ravipesala ravindra.pesalahuawei.com
Author: ravipesala <ra...@huawei.com>
Closes #2737 from ravipesala/SPARK-3834 and squashes the following commits:
0e0ab98 [ravipesala] Fixing issue in backtick handling for subquery aliases
Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/6f98902a
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/6f98902a
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/6f98902a
Branch: refs/heads/master
Commit: 6f98902a3d7749e543bc493a8c62b1e3a7b924cc
Parents: 421382d
Author: ravipesala <ra...@huawei.com>
Authored: Thu Oct 9 18:41:36 2014 -0700
Committer: Michael Armbrust <mi...@databricks.com>
Committed: Thu Oct 9 18:41:36 2014 -0700
----------------------------------------------------------------------
.../src/main/scala/org/apache/spark/sql/hive/HiveQl.scala | 2 +-
.../org/apache/spark/sql/hive/execution/SQLQuerySuite.scala | 8 +++++++-
2 files changed, 8 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/spark/blob/6f98902a/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveQl.scala
----------------------------------------------------------------------
diff --git a/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveQl.scala b/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveQl.scala
index 98a46a3..7cc14dc 100644
--- a/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveQl.scala
+++ b/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveQl.scala
@@ -638,7 +638,7 @@ private[hive] object HiveQl {
def nodeToRelation(node: Node): LogicalPlan = node match {
case Token("TOK_SUBQUERY",
query :: Token(alias, Nil) :: Nil) =>
- Subquery(alias, nodeToPlan(query))
+ Subquery(cleanIdentifier(alias), nodeToPlan(query))
case Token(laterViewToken(isOuter), selectClause :: relationClause :: Nil) =>
val Token("TOK_SELECT",
http://git-wip-us.apache.org/repos/asf/spark/blob/6f98902a/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/SQLQuerySuite.scala
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/SQLQuerySuite.scala b/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/SQLQuerySuite.scala
index 3647bb1..fbe6ac7 100644
--- a/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/SQLQuerySuite.scala
+++ b/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/SQLQuerySuite.scala
@@ -68,5 +68,11 @@ class SQLQuerySuite extends QueryTest {
checkAnswer(
sql("SELECT k FROM (SELECT `key` AS `k` FROM src) a"),
sql("SELECT `key` FROM src").collect().toSeq)
- }
+ }
+
+ test("SPARK-3834 Backticks not correctly handled in subquery aliases") {
+ checkAnswer(
+ sql("SELECT a.key FROM (SELECT key FROM src) `a`"),
+ sql("SELECT `key` FROM src").collect().toSeq)
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org