panbingkun commented on code in PR #47648:
URL: https://github.com/apache/spark/pull/47648#discussion_r1710578026
##########
sql/core/src/test/scala/org/apache/spark/sql/scripting/SqlScriptingInterpreterSuite.scala:
##########
@@ -362,4 +367,48 @@ class SqlScriptingInterpreterSuite extends QueryTest with
SharedSparkSession {
verifySqlScriptResult(commands, expected)
}
}
+
+ test("if's condition must be a boolean statement") {
+ withTable("t") {
+ val commands =
+ """
+ |BEGIN
+ | IF 1 THEN
+ | SELECT 45;
+ | END IF;
+ |END
+ |""".stripMargin
+ checkError(
+ exception = intercept[SqlScriptingException] (
+ runSqlScript(commands)
+ ),
+ errorClass = "INVALID_BOOLEAN_STATEMENT",
+ parameters = Map("invalidStatement" -> "1")
+ )
+ }
+ }
+
+ test("if's condition must return a single row data") {
Review Comment:
@davidm-db
Although I have split it into `2 error conditions`
(`INVALID_BOOLEAN_STATEMENT` and `BOOLEAN_STATEMENT_TOO_MANY_ROWS`) as per your
suggestion, but unfortunately, it seems impossible to hit it, as shown in this
case.
It hit an error `SCALAR_SUBQUERY_TOO_MANY_ROWS`.
--
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]