yeshengm commented on a change in pull request #24809: [SPARK-21136][SQL] Fix
confusing parsing error due to problematic antlr grammer for Hive-style
single-from statements
URL: https://github.com/apache/spark/pull/24809#discussion_r291373165
##########
File path:
sql/catalyst/src/main/antlr4/org/apache/spark/sql/catalyst/parser/SqlBase.g4
##########
@@ -420,25 +416,58 @@ sortItem
: expression ordering=(ASC | DESC)? (NULLS nullOrder=(LAST | FIRST))?
;
+fromStatement
+ : fromClause fromStatementBody+
+ ;
+
+fromStatementBody
+ : transformClause
+ whereClause?
+ queryOrganization
+ | selectClause
+ lateralView*
+ whereClause?
+ aggregationClause?
+ havingClause?
+ windowClause?
+ queryOrganization
+ ;
+
querySpecification
- : (((SELECT kind=TRANSFORM '(' namedExpressionSeq ')'
- | kind=MAP namedExpressionSeq
- | kind=REDUCE namedExpressionSeq))
- inRowFormat=rowFormat?
- (RECORDWRITER recordWriter=STRING)?
- USING script=STRING
- (AS (identifierSeq | colTypeList | ('(' (identifierSeq | colTypeList)
')')))?
- outRowFormat=rowFormat?
- (RECORDREADER recordReader=STRING)?
- fromClause?
- (WHERE where=booleanExpression)?)
- | ((kind=SELECT (hints+=hint)* setQuantifier? namedExpressionSeq
fromClause?
- | fromClause (kind=SELECT setQuantifier? namedExpressionSeq)?)
- lateralView*
- (WHERE where=booleanExpression)?
- aggregation?
- (HAVING having=booleanExpression)?
- windows?)
+ : transformClause
Review comment:
Re-write `querySpecification` to show the fact that transform and select are
two different kinds of queries.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]