You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by da...@apache.org on 2016/01/09 06:48:11 UTC
spark git commit: [SPARK-12577] [SQL] Better support of parentheses
in partition by and order by clause of window function's over clause
Repository: spark
Updated Branches:
refs/heads/master 090d69132 -> 95cd5d95c
[SPARK-12577] [SQL] Better support of parentheses in partition by and order by clause of window function's over clause
JIRA: https://issues.apache.org/jira/browse/SPARK-12577
Author: Liang-Chi Hsieh <vi...@gmail.com>
Closes #10620 from viirya/fix-parentheses.
Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/95cd5d95
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/95cd5d95
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/95cd5d95
Branch: refs/heads/master
Commit: 95cd5d95ce8aec8b2462204c791ba927326305ba
Parents: 090d691
Author: Liang-Chi Hsieh <vi...@gmail.com>
Authored: Fri Jan 8 21:48:06 2016 -0800
Committer: Davies Liu <da...@gmail.com>
Committed: Fri Jan 8 21:48:06 2016 -0800
----------------------------------------------------------------------
.../sql/catalyst/parser/ExpressionParser.g | 7 +++-
.../spark/sql/catalyst/CatalystQlSuite.scala | 36 ++++++++++++++------
2 files changed, 32 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/spark/blob/95cd5d95/sql/catalyst/src/main/antlr3/org/apache/spark/sql/catalyst/parser/ExpressionParser.g
----------------------------------------------------------------------
diff --git a/sql/catalyst/src/main/antlr3/org/apache/spark/sql/catalyst/parser/ExpressionParser.g b/sql/catalyst/src/main/antlr3/org/apache/spark/sql/catalyst/parser/ExpressionParser.g
index cad7701..aabb5d4 100644
--- a/sql/catalyst/src/main/antlr3/org/apache/spark/sql/catalyst/parser/ExpressionParser.g
+++ b/sql/catalyst/src/main/antlr3/org/apache/spark/sql/catalyst/parser/ExpressionParser.g
@@ -223,7 +223,12 @@ precedenceUnaryPrefixExpression
;
precedenceUnarySuffixExpression
- : precedenceUnaryPrefixExpression (a=KW_IS nullCondition)?
+ :
+ (
+ (LPAREN precedenceUnaryPrefixExpression RPAREN) => LPAREN precedenceUnaryPrefixExpression (a=KW_IS nullCondition)? RPAREN
+ |
+ precedenceUnaryPrefixExpression (a=KW_IS nullCondition)?
+ )
-> {$a != null}? ^(TOK_FUNCTION nullCondition precedenceUnaryPrefixExpression)
-> precedenceUnaryPrefixExpression
;
http://git-wip-us.apache.org/repos/asf/spark/blob/95cd5d95/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/CatalystQlSuite.scala
----------------------------------------------------------------------
diff --git a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/CatalystQlSuite.scala b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/CatalystQlSuite.scala
index 30978d9..d7204c3 100644
--- a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/CatalystQlSuite.scala
+++ b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/CatalystQlSuite.scala
@@ -20,17 +20,33 @@ package org.apache.spark.sql.catalyst
import org.apache.spark.sql.catalyst.plans.PlanTest
class CatalystQlSuite extends PlanTest {
+ val parser = new CatalystQl()
test("parse union/except/intersect") {
- val paresr = new CatalystQl()
- paresr.createPlan("select * from t1 union all select * from t2")
- paresr.createPlan("select * from t1 union distinct select * from t2")
- paresr.createPlan("select * from t1 union select * from t2")
- paresr.createPlan("select * from t1 except select * from t2")
- paresr.createPlan("select * from t1 intersect select * from t2")
- paresr.createPlan("(select * from t1) union all (select * from t2)")
- paresr.createPlan("(select * from t1) union distinct (select * from t2)")
- paresr.createPlan("(select * from t1) union (select * from t2)")
- paresr.createPlan("select * from ((select * from t1) union (select * from t2)) t")
+ parser.createPlan("select * from t1 union all select * from t2")
+ parser.createPlan("select * from t1 union distinct select * from t2")
+ parser.createPlan("select * from t1 union select * from t2")
+ parser.createPlan("select * from t1 except select * from t2")
+ parser.createPlan("select * from t1 intersect select * from t2")
+ parser.createPlan("(select * from t1) union all (select * from t2)")
+ parser.createPlan("(select * from t1) union distinct (select * from t2)")
+ parser.createPlan("(select * from t1) union (select * from t2)")
+ parser.createPlan("select * from ((select * from t1) union (select * from t2)) t")
+ }
+
+ test("window function: better support of parentheses") {
+ parser.createPlan("select sum(product + 1) over (partition by ((1) + (product / 2)) " +
+ "order by 2) from windowData")
+ parser.createPlan("select sum(product + 1) over (partition by (1 + (product / 2)) " +
+ "order by 2) from windowData")
+ parser.createPlan("select sum(product + 1) over (partition by ((product / 2) + 1) " +
+ "order by 2) from windowData")
+
+ parser.createPlan("select sum(product + 1) over (partition by ((product) + (1)) order by 2) " +
+ "from windowData")
+ parser.createPlan("select sum(product + 1) over (partition by ((product) + 1) order by 2) " +
+ "from windowData")
+ parser.createPlan("select sum(product + 1) over (partition by (product + (1)) order by 2) " +
+ "from windowData")
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org