-
Notifications
You must be signed in to change notification settings - Fork 28.3k
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
[SPARK-20311][SQL] Support aliases for table value functions #17928
Conversation
emp 5 1000.0 | ||
emp 6 - no dept 500.0 | ||
org.apache.spark.SparkException | ||
Exception thrown in awaitResult: |
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.
are we breaking existing queries?
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.
oh, my bad. I'll check again.
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.
Fixed.
Test build #76712 has finished for PR 17928 at commit
|
Test build #76716 has finished for PR 17928 at commit
|
@cloud-fan ok, could you check again? Thanks! |
LGTM, cc @gatorsmile to take another look |
; | ||
|
||
tableAlias | ||
: (AS? strictIdentifier identifierList?)? |
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.
This also hits another bug in inline tables. Maybe you also can include the following query in the test case inline-table.sql
?
sql("SELECT * FROM VALUES (\"one\", 1), (\"three\", null) CROSS JOIN VALUES (\"one\", 1), (\"three\", null)")
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.
Added.
|
||
test("SPARK-20311 range(N) as alias") { | ||
assertEqual( | ||
"select * from range(10) AS t", |
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.
Nit: SELECT * FROM range(10) AS t
BTW, we prefer to use upper case for the SQL keywords.
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.
You also can update the similar issues in your test cases.
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.
ok
LGTM |
Test build #76737 has finished for PR 17928 at commit
|
@@ -24,3 +24,7 @@ select * from RaNgE(2); | |||
|
|||
-- Explain | |||
EXPLAIN select * from RaNgE(2); | |||
|
|||
-- cross-join table valued functions | |||
SET spark.sql.crossJoin.enabled=true; |
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.
Could you remove this line? If we specify CROSS JOIN in the query, no need to set this parm.
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.
ok
Test build #76770 has finished for PR 17928 at commit
|
@@ -49,3 +49,6 @@ select * from values ("one", count(1)), ("two", 2) as data(a, b); | |||
|
|||
-- string to timestamp | |||
select * from values (timestamp('1991-12-06 00:00:00.0'), array(timestamp('1991-12-06 01:00:00.0'), timestamp('1991-12-06 12:00:00.0'))) as data(a, b); | |||
|
|||
-- cross-join inline tables | |||
SELECT * FROM VALUES ('one', 1), ('three', null) CROSS JOIN VALUES ('one', 1), ('three', null); |
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.
does this expose the bug? If we treat CROSS as an alias, we still get the same result. how about we run EXPLAIN?
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.
Aha, ok
Test build #76784 has started for PR 17928 at commit |
retest this please |
Test build #76791 has finished for PR 17928 at commit
|
Thanks! Merging to master. |
## What changes were proposed in this pull request? This pr added parsing rules to support aliases in table value functions. The previous pr (apache#17666) has been reverted because of the regression. This new pr fixed the regression and add tests in `SQLQueryTestSuite`. ## How was this patch tested? Added tests in `PlanParserSuite` and `SQLQueryTestSuite`. Author: Takeshi Yamamuro <yamamuro@apache.org> Closes apache#17928 from maropu/SPARK-20311-3.
What changes were proposed in this pull request?
This pr added parsing rules to support aliases in table value functions.
The previous pr (#17666) has been reverted because of the regression. This new pr fixed the regression and add tests in
SQLQueryTestSuite
.How was this patch tested?
Added tests in
PlanParserSuite
andSQLQueryTestSuite
.