-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-13321][SQL] Add nested union test cases #11361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
93bd51e
f462997
190b326
a00261d
d024fff
1e34c44
5ff5ac2
c616664
4d93e9e
6775020
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1114,6 +1114,91 @@ class HiveQuerySuite extends HiveComparisonTest with BeforeAndAfter { | |
| } | ||
| } | ||
|
|
||
| test("nested union") { | ||
| sql( | ||
| """ | ||
| | EXPLAIN | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the point of this SQL statement? See if it compiles?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Previous solution to the ANTLR3 parser will hang on this query. |
||
| | SELECT count(1) FROM ( | ||
| | SELECT key, value FROM src UNION ALL | ||
| | SELECT key, value FROM src UNION ALL | ||
| | SELECT key, value FROM src UNION ALL | ||
| | SELECT key, value FROM src UNION ALL | ||
| | SELECT key, value FROM src UNION ALL | ||
| | | ||
| | SELECT key, value FROM src UNION ALL | ||
| | SELECT key, value FROM src UNION ALL | ||
| | SELECT key, value FROM src UNION ALL | ||
| | SELECT key, value FROM src UNION ALL | ||
| | SELECT key, value FROM src UNION ALL | ||
| | | ||
| | SELECT key, value FROM src UNION ALL | ||
| | SELECT key, value FROM src UNION ALL | ||
| | SELECT key, value FROM src UNION ALL | ||
| | SELECT key, value FROM src UNION ALL | ||
| | SELECT key, value FROM src UNION ALL | ||
| | | ||
| | SELECT key, value FROM src UNION ALL | ||
| | SELECT key, value FROM src UNION ALL | ||
| | SELECT key, value FROM src UNION ALL | ||
| | SELECT key, value FROM src UNION ALL | ||
| | SELECT key, value FROM src UNION ALL | ||
| | | ||
| | SELECT key, value FROM src UNION ALL | ||
| | SELECT key, value FROM src UNION ALL | ||
| | SELECT key, value FROM src UNION ALL | ||
| | SELECT key, value FROM src UNION ALL | ||
| | SELECT key, value FROM src) src | ||
| """.stripMargin) | ||
|
|
||
| val countForSrc = sql("SELECT count(1) FROM src").first() | ||
|
|
||
| val countForUnion25Src = sql( | ||
| """ | ||
| | SELECT count(1) FROM ( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems a bit redundant to write the allmost the same query as above...
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ha. sure. let me update this. |
||
| | SELECT key, value FROM src UNION ALL | ||
| | SELECT key, value FROM src UNION ALL | ||
| | SELECT key, value FROM src UNION ALL | ||
| | SELECT key, value FROM src UNION ALL | ||
| | SELECT key, value FROM src UNION ALL | ||
| | | ||
| | SELECT key, value FROM src UNION ALL | ||
| | SELECT key, value FROM src UNION ALL | ||
| | SELECT key, value FROM src UNION ALL | ||
| | SELECT key, value FROM src UNION ALL | ||
| | SELECT key, value FROM src UNION ALL | ||
| | | ||
| | SELECT key, value FROM src UNION ALL | ||
| | SELECT key, value FROM src UNION ALL | ||
| | SELECT key, value FROM src UNION ALL | ||
| | SELECT key, value FROM src UNION ALL | ||
| | SELECT key, value FROM src UNION ALL | ||
| | | ||
| | SELECT key, value FROM src UNION ALL | ||
| | SELECT key, value FROM src UNION ALL | ||
| | SELECT key, value FROM src UNION ALL | ||
| | SELECT key, value FROM src UNION ALL | ||
| | SELECT key, value FROM src UNION ALL | ||
| | | ||
| | SELECT key, value FROM src UNION ALL | ||
| | SELECT key, value FROM src UNION ALL | ||
| | SELECT key, value FROM src UNION ALL | ||
| | SELECT key, value FROM src UNION ALL | ||
| | SELECT key, value FROM src) src | ||
| """.stripMargin).first() | ||
|
|
||
| assert(countForSrc.getLong(0) == 500) | ||
| assert(countForUnion25Src.getLong(0) == 500 * 25) | ||
|
|
||
| val nested = sql( | ||
| """ | ||
| | SELECT u_1.key FROM (((SELECT key FROM src) | ||
| | UNION ALL (SELECT key FROM src)) UNION ALL | ||
| | (SELECT key FROM src)) AS u_1 | ||
| """.stripMargin).collect() | ||
|
|
||
| assert(nested.size == 500 * 3) | ||
| } | ||
|
|
||
| test("parse HQL set commands") { | ||
| // Adapted from its SQL counterpart. | ||
| val testKey = "spark.sql.key.usedfortestonly" | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor: @viirya could you update this use the DSL and
assertEqualequals? It makes this a bit easier to read.BTW this test is very similar to the following test case: https://github.com/apache/spark/blob/master/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/parser/PlanParserSuite.scala#L384-L392
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm. indeed. If so, I think I can close this pr now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hvanhovell Is new ANTLR4 parser natively to solve this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@viirya the new parser handles nested queries a lot better. This is mainly due to ANTLR4's better parsing algorithms.