LuciferYang commented on code in PR #49427: URL: https://github.com/apache/spark/pull/49427#discussion_r1944392967
########## sql/core/src/test/scala/org/apache/spark/sql/scripting/SqlScriptingExecutionSuite.scala: ########## @@ -65,6 +69,557 @@ class SqlScriptingExecutionSuite extends QueryTest with SharedSparkSession { } } + // Handler tests + test("duplicate handler for the same condition") { + val sqlScript = + """ + |BEGIN + | DECLARE duplicate_condition CONDITION FOR SQLSTATE '12345'; + | DECLARE OR REPLACE flag INT = -1; + | DECLARE EXIT HANDLER FOR duplicate_condition + | BEGIN + | SET VAR flag = 1; + | END; + | DECLARE EXIT HANDLER FOR duplicate_condition + | BEGIN + | SET VAR flag = 2; + | END; + | SELECT 1/0; + | SELECT flag; + |END + |""".stripMargin + checkError( + exception = intercept[SqlScriptingException] { + verifySqlScriptResult(sqlScript, Seq.empty) + }, + condition = "DUPLICATE_EXCEPTION_HANDLER.CONDITION", + parameters = Map("condition" -> "DUPLICATE_CONDITION")) + } + + test("duplicate handler for the same sqlState") { + val sqlScript = + """ + |BEGIN + | DECLARE OR REPLACE flag INT = -1; + | DECLARE EXIT HANDLER FOR SQLSTATE '12345' + | BEGIN + | SET VAR flag = 1; + | END; + | DECLARE EXIT HANDLER FOR SQLSTATE '12345' + | BEGIN + | SET VAR flag = 2; + | END; + | SELECT 1/0; + | SELECT flag; + |END + |""".stripMargin + checkError( + exception = intercept[SqlScriptingException] { + verifySqlScriptResult(sqlScript, Seq.empty) + }, + condition = "DUPLICATE_EXCEPTION_HANDLER.SQLSTATE", + parameters = Map("sqlState" -> "12345")) + } + + test("Specific condition takes precedence over sqlState") { Review Comment: > let's just enable ansi for the entire suite, by overriding `def sparkConf`. example: > > ``` > class AvroV1Suite extends AvroSuite { > override protected def sparkConf: SparkConf = > super > .sparkConf > .set(SQLConf.USE_V1_SOURCE_LIST, "avro") > ``` If the 13 failed cases are all due to the same reason, I think it's ok -- 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: reviews-unsubscr...@spark.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org