dtenedor commented on code in PR #48724:
URL: https://github.com/apache/spark/pull/48724#discussion_r1839090357


##########
sql/api/src/main/antlr4/org/apache/spark/sql/catalyst/parser/SqlBaseParser.g4:
##########
@@ -643,7 +643,7 @@ sortItem
     ;
 
 fromStatement
-    : fromClause fromStatementBody+
+    : fromClause (fromStatementBody)*

Review Comment:
   @cloud-fan The parser rule is used by both pipe SQL syntax as well as 
regular SQL syntax. Currently, we support the `fromStatement` is a valid entire 
SQL query:
   
   ```
   queryPrimary
       : querySpecification         #queryPrimaryDefault
       | fromStatement              #fromStmt
       ...
   
   fromStatement
       : fromClause fromStatementBody+
       ;
   
   fromStatementBody
       : transformClause
         whereClause?
         queryOrganization
       | selectClause
         lateralView*
         whereClause?
         ...
       ;
   ```
   
   So for example, `FROM t SELECT a, b` is a valid Spark SQL query.
   
   Therefore it is also valid to write `FROM t SELECT * |> WHERE a = 42`.
   
   This PR is making the second part optional, so you could write `FROM t` as 
equivalent to `TABLE t` to return the entire table, or `FROM t |> WHERE a = 42`.
   
   Let us know if this is OK to you or if we should restrict the grammar 
changes to only applying to SQL pipe syntax only.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to