miland-db commented on code in PR #53530:
URL: https://github.com/apache/spark/pull/53530#discussion_r2661188274
##########
sql/core/src/main/scala/org/apache/spark/sql/scripting/SqlScriptingExecutionNode.scala:
##########
@@ -313,6 +319,34 @@ class CompoundBodyExec(
@tailrec
override def next(): CompoundStatementExec = {
+ // If we need to return current without advancing (after CONTINUE
handler),
Review Comment:
`CONTINUE HANDLER` has a known bug and a fix is currently in progress.
Specifically, it does not behave correctly when the handled statement is
executed inside a loop.
The following example fails with the current implementation:
```
BEGIN
-- Multi-variable declaration (New in 4.1)
DECLARE x, y = 1;
-- Define error handling logic
DECLARE CONTINUE HANDLER FOR DIVIDE_BY_ZERO
BEGIN
SET y = -1;
END;
-- Loop logic
WHILE x < 8 DO
SET x = x + 1;
-- This might throw a divide-by-zero error, but the handler will catch it
SET y = y / (x - 3);
END WHILE;
SELECT x, y;
END;
```
I am working on fixing this issue and plan to send a dedicated PR for review
in the coming days.
Given that this area of the code is particularly touchy, I’d strongly prefer
that we review the other parts of this PR first. The current approach here
feels somewhat hacky, and building additional logic on top of `CONTINUE
HANDLER` is risky at this stage.
--
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]