Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,12 @@ precedenceUnaryPrefixExpression
;

precedenceUnarySuffixExpression
: precedenceUnaryPrefixExpression (a=KW_IS nullCondition)?
:
(
(LPAREN precedenceUnaryPrefixExpression RPAREN) => LPAREN precedenceUnaryPrefixExpression (a=KW_IS nullCondition)? RPAREN
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this support (a is null) ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I think so.

|
precedenceUnaryPrefixExpression (a=KW_IS nullCondition)?
)
-> {$a != null}? ^(TOK_FUNCTION nullCondition precedenceUnaryPrefixExpression)
-> precedenceUnaryPrefixExpression
;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}