cloud-fan commented on code in PR #55466:
URL: https://github.com/apache/spark/pull/55466#discussion_r3329900456


##########
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/util/StringUtilsSuite.scala:
##########
@@ -287,5 +287,40 @@ class StringUtilsSuite extends SparkFunSuite with 
SQLHelper {
           |END""".stripMargin
       )
     )
+
+    // SPARK-54876: statement after semicolon ending with block comment should 
not be dropped
+    assert(
+      splitSemiColonWithIndex(
+        "SELECT 1; SELECT 2 /* comment */",
+        enableSqlScripting = false) == Seq("SELECT 1", " SELECT 2 /* comment 
*/")
+    )
+
+    // SPARK-54876: line comment followed by block comment should produce 
empty result
+    assert(
+      splitSemiColonWithIndex(
+        "-- foo\n/* bar */",
+        enableSqlScripting = false) == Seq()
+    )
+
+    // SPARK-54876: line comment before block comment after semicolon
+    assert(
+      splitSemiColonWithIndex(
+        "SELECT 1; -- foo\n /* bar */",
+        enableSqlScripting = false) == Seq("SELECT 1")
+    )
+
+    // SPARK-54876: nested block comments
+    assert(
+      splitSemiColonWithIndex(
+        "SELECT 1; /* outer /* inner */ */",
+        enableSqlScripting = false) == Seq("SELECT 1")
+    )
+
+    // SPARK-54876: preceding closed block comment + line comment (no SQL 
statement)

Review Comment:
   The rewrite introduces `chunkHasUnclosed` 
(StringUtils.scala:295/305/323/343) to forward an unterminated string or block 
comment at EOF to the backend, but no test asserts that path. Consider adding 
e.g. `"SELECT 1; /* unterminated"` -> `Seq("SELECT 1", " /* unterminated")` and 
`"'unterminated"` -> `Seq("'unterminated")` here. (Late catch -- my own miss 
from when the structural scanner landed.)



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