Skip to content

[SPARK-52489][SQL] Forbid duplicate SQLEXCEPTION and NOT FOUND handlers inside SQL Script #51168

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

miland-db
Copy link
Contributor

What changes were proposed in this pull request?

In this PR we forbid duplicate SQLEXCEPTION or NOT FOUND exception handlers to be defined in the same scope. This was already done for different conditions and sqlstates but was not done for these 2 types of exception handlers. Code like this should fail:

BEGIN
  DECLARE EXIT HANDLER FOR NOT FOUND
  BEGIN
    SELECT 1;
  END;
  DECLARE EXIT HANDLER FOR NOT FOUND
  BEGIN
    SELECT 2;
  END;
END

Why are the changes needed?

This is a bug fix.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

New tests in SqlScriptingInterpreterSuite.

Was this patch authored or co-authored using generative AI tooling?

No.

@github-actions github-actions bot added the SQL label Jun 12, 2025
@miland-db
Copy link
Contributor Author

Adding @cloud-fan , @davidm-db, @MaxGekk

@cloud-fan
Copy link
Contributor

SqlScriptingInterpreterSuite fails

@cloud-fan
Copy link
Contributor

Let's create a JIRA ticket. This is not a minor change. Otherwise LGTM

@miland-db miland-db changed the title [SQL][MINOR] Forbid duplicate SQLEXCEPTION and NOT FOUND handlers inside SQL Script [SPARK-52489][SQL] Forbid duplicate SQLEXCEPTION and NOT FOUND handlers inside SQL Script Jun 16, 2025
@miland-db
Copy link
Contributor Author

Hey @cloud-fan, I created a JIRA ticket. Thanks for the review!

@cloud-fan
Copy link
Contributor

thanks, merging to master/4.0!

@cloud-fan cloud-fan closed this in 23cf926 Jun 19, 2025
cloud-fan pushed a commit that referenced this pull request Jun 19, 2025
…rs inside SQL Script

### What changes were proposed in this pull request?
In this PR we forbid duplicate SQLEXCEPTION or NOT FOUND exception handlers to be defined in the same scope. This was already done for different conditions and sqlstates but was not done for these 2 types of exception handlers. Code like this should fail:

```
BEGIN
  DECLARE EXIT HANDLER FOR NOT FOUND
  BEGIN
    SELECT 1;
  END;
  DECLARE EXIT HANDLER FOR NOT FOUND
  BEGIN
    SELECT 2;
  END;
END
```

### Why are the changes needed?
This is a bug fix.

### Does this PR introduce _any_ user-facing change?
No.

### How was this patch tested?
New tests in `SqlScriptingInterpreterSuite`.

### Was this patch authored or co-authored using generative AI tooling?
No.

Closes #51168 from miland-db/milan-dankovic_data/forbid-duplicate-handlers.

Authored-by: Milan Dankovic <[email protected]>
Signed-off-by: Wenchen Fan <[email protected]>
(cherry picked from commit 23cf926)
Signed-off-by: Wenchen Fan <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants