-
Notifications
You must be signed in to change notification settings - Fork 28.6k
[SPARK-27209][SQL] Split parsing of SELECT and INSERT into two top-level rules in the grammar file. #24150
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-27209][SQL] Split parsing of SELECT and INSERT into two top-level rules in the grammar file. #24150
Changes from all commits
0e61c95
fa07a73
18afacd
f7aaebd
ea05263
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 |
---|---|---|
|
@@ -81,6 +81,8 @@ singleTableSchema | |
|
||
statement | ||
: query #statementDefault | ||
| insertStatement #insertStatementDefault | ||
| multiSelectStatement #multiSelectStatementDefault | ||
| USE db=identifier #use | ||
| CREATE database (IF NOT EXISTS)? identifier | ||
(COMMENT comment=STRING)? locationSpec? | ||
|
@@ -358,9 +360,14 @@ resource | |
: identifier STRING | ||
; | ||
|
||
insertStatement | ||
: (ctes)? insertInto queryTerm queryOrganization #singleInsertQuery | ||
| (ctes)? fromClause multiInsertQueryBody+ #multiInsertQuery | ||
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. shall we change the 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. @cloud-fan did you mean make insertInto non-optional in 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. why do we still need https://github.com/apache/spark/pull/24150/files#diff-8c1cb2af4aa1109e08481dae79052cc3R365 ? 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. @cloud-fan If you don't mind, could you please paste the block or line here ? When i click on that link, it shows me pretty much all the changes so i am not sure which one i should focus on. 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. @dilipbiswal . He means line 365. And, that's the same question with the below comment, https://github.com/apache/spark/pull/24150/files#r267283726.
Line 365 is required for 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. @dongjoon-hyun Thanks for helping out. When i clicked.. it took me to AstBuilder ... so i was confused. @cloud-fan So we need the rule to parse statement i mentioned earlier.
It is parsed sort of recursively in the 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.
and in 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. @cloud-fan Currently after this change, fromClause and multiple querySpecification queryOrganization will be handled by 2nd alternative of the insertStatement. I know that this may look confusing. In this pass, i wanted to handle single queries in one rule which is 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. @cloud-fan instead of name 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. I also think why we keep 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. We cannot write it like this?
|
||
; | ||
|
||
queryNoWith | ||
: insertInto? queryTerm queryOrganization #singleInsertQuery | ||
| fromClause multiInsertQueryBody+ #multiInsertQuery | ||
: queryTerm queryOrganization #noWithQuery | ||
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. Actually, 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. @dongjoon-hyun would you have any suggestion ? I was thinking |
||
| fromClause selectStatement #queryWithFrom | ||
; | ||
|
||
queryOrganization | ||
|
@@ -373,9 +380,15 @@ queryOrganization | |
; | ||
|
||
multiInsertQueryBody | ||
: insertInto? | ||
querySpecification | ||
queryOrganization | ||
: insertInto selectStatement | ||
; | ||
|
||
multiSelectStatement | ||
: (ctes)? fromClause selectStatement+ #multiSelect | ||
; | ||
|
||
selectStatement | ||
: querySpecification queryOrganization | ||
; | ||
|
||
queryTerm | ||
|
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.
Can you move
(ctes)?
to the line 80 like| (ctes)? insertStatement
?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.
@maropu then i may have to implement/override another visit method to apply the cte to an insert statement, okay ?
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.
the duplicate patten?
Uh oh!
There was an error while loading. Please reload this page.
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.
@maropu Thats right. After this PR is in, i will have a follow-up to allow CTEs for DESCRIBE QUERY (currently it is a limitation) and that would remove this pattern all together (i hope :-) ).