davidm-db commented on code in PR #46665:
URL: https://github.com/apache/spark/pull/46665#discussion_r1636111527


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AbstractSqlParser.scala:
##########
@@ -91,6 +91,19 @@ abstract class AbstractSqlParser extends AbstractParser with 
ParserInterface {
     }
   }
 
+  /** Creates [[CompoundBody]] for a given SQL script string. */
+  override def parseScript(sqlScriptText: String): CompoundBody = 
parse(sqlScriptText) { parser =>
+    val ctx = parser.compoundOrSingleStatement()
+    withErrorHandling(ctx, Some(sqlScriptText)) {
+      astBuilder.visitCompoundOrSingleStatement(ctx) match {
+        case body: CompoundBody => body
+        case _ =>
+          val position = Origin(None, None)
+          throw QueryParsingErrors.sqlStatementUnsupportedError(sqlScriptText, 
position)

Review Comment:
   Basically, we did the same as in `parsePlan`, but in my opinion this means 
bug... This would happen if parsing is successful, but something other than 
expected node (`CompoundBody` here) is returned, which I have no idea how it 
could happen. If something is bad, I would expect Syntax/Parsing exception to 
be thrown, otherwise the `sqlScriptText` should be parsed into `CompoundBody`. 
So, I don't expect this case to ever be hit, but we copied the `parsePlan` 
behavior.
   
   Of course, I might be missing something here...



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