pan3793 commented on code in PR #54946:
URL: https://github.com/apache/spark/pull/54946#discussion_r3464962993
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/ParserInterface.scala:
##########
@@ -80,4 +80,24 @@ trait ParserInterface extends DataTypeParserInterface {
*/
@throws[ParseException]("Text cannot be parsed to routine parameters")
def parseRoutineParam(sqlText: String): StructType
+
+ /**
+ * Split a SQL string into individual statements at `;` boundaries.
+ *
+ * Designed for tooling such as the `spark-sql` CLI that needs to feed
multiple
+ * statements to the parser one at a time, while correctly handling quoted
+ * strings, single-line and bracketed comments, and SQL scripting compound
blocks
+ * (`BEGIN ... END`) so that semicolons inside them do not split the
surrounding
+ * statement.
+ *
+ * The method is fault-tolerant: it does not throw on incomplete or malformed
+ * input. Trailing text that does not yet form a complete statement is
returned
+ * in [[SqlStatementSplitResult.partialStatement]] so callers can buffer it
and
+ * read more input.
+ *
+ * Implementations are expected to apply the same input preprocessing
(variable
+ * substitution, etc.) as their `parsePlan` so that the splitter sees the
same
+ * stream of tokens the parser would.
+ */
+ def splitStatements(sqlText: String): SqlStatementSplitResult
Review Comment:
the current `SqlStatementSplitter.split` only covers simple extended SQL
syntax; if the plugin extends complex SQL syntax, for example,
```
CREATE PROCEDURE procedure_name AS
BEGIN
...
END
```
it still requires that the plugin implement its own splitter
--
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]