miland-db commented on code in PR #53530:
URL: https://github.com/apache/spark/pull/53530#discussion_r2690577969


##########
sql/core/src/main/scala/org/apache/spark/sql/scripting/SqlScriptingExecution.scala:
##########
@@ -224,7 +305,18 @@ class SqlScriptingExecution(
         handler.reset()
         handlerFrame.executionPlan.enterScope()
       case None =>
-        throw e.asInstanceOf[Throwable]
+        // SQL Standard: Unhandled completion conditions (SQLSTATE class '02' 
- no data)
+        // continue execution after the statement that caused the condition.
+        // Unhandled exception conditions (all other classes) are resignaled 
(thrown).
+        // Note: SQLSTATE class '01' (warnings) are not currently raised by 
Spark.
+        val sqlState = e.getSqlState
+        if (sqlState != null && sqlState.startsWith("02")) {
+          // Completion condition (no data) - continue execution, don't throw
+          // This allows statements like FETCH to return "no data" without 
causing script failure
+        } else {
+          // Exception condition - resignal (throw)
+          throw e.asInstanceOf[Throwable]
+        }

Review Comment:
   I would prefer to not have empty if body:
   ```
   case None =>
     val sqlState = e.getSqlState
     val isCompletionCondition = sqlState != null && sqlState.startsWith("02")
   
     if (!isCompletionCondition) {
       throw e.asInstanceOf[Throwable]
     }
   ```



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