miland-db opened a new pull request, #53760:
URL: https://github.com/apache/spark/pull/53760
### What changes were proposed in this pull request?
An unexpected behavior happens when an EXIT handler inside of an outer scope
gets triggered by an exception inside an EXIT handler thats inside an inner
nested scope: instead of leaving the outer scope after finishing all the
exception handling, execution only leaves the inner scope.
In the example below, execution returns 3, 2 at the end, but it shouldn't
reach that part of the code.
```
BEGIN
DECLARE VARIABLE flag INT = -1;
l1: BEGIN
DECLARE EXIT HANDLER FOR UNRESOLVED_COLUMN.WITHOUT_SUGGESTION
BEGIN
SELECT flag;
SET flag = 2;
END;
l2: BEGIN
DECLARE EXIT HANDLER FOR DIVIDE_BY_ZERO
BEGIN
SELECT flag;
SET flag = 1;
select X; -- select non existing variable
SELECT 2;
END;
SELECT 5;
SELECT 1/0; -- divide by zero
SELECT 6;
END l2;
SELECT 3, flag;
END l1;
END
```
In this PR I propose a fix for this issue.
### Why are the changes needed?
This change is needed to fix the correctness behavior of the SQL Scripting
engine.
### Does this PR introduce _any_ user-facing change?
No.
### How was this patch tested?
New unit tests.
### Was this patch authored or co-authored using generative AI tooling?
No.
--
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]