[SPARK-55109][SQL] Enhance RaiseError to generate valid SQL#55115
Open
felipepessoto wants to merge 2 commits intoapache:masterfrom
Open
[SPARK-55109][SQL] Enhance RaiseError to generate valid SQL#55115felipepessoto wants to merge 2 commits intoapache:masterfrom
felipepessoto wants to merge 2 commits intoapache:masterfrom
Conversation
Author
cloud-fan
reviewed
Apr 2, 2026
|
|
||
| override def sql: String = { | ||
| // When constructed from the single-argument form (just an error message string), | ||
| // output only the original message to produce valid, roundtrippable SQL. |
Contributor
There was a problem hiding this comment.
shall we check the errorClass as well? to be _LEGACY_ERROR_USER_RAISED_EXCEPTION or USER_RAISED_EXCEPTION
Author
…s is USER_RAISED_EXCEPTION or _LEGACY_ERROR_USER_RAISED_EXCEPTION, which are the two values set by the single-argument constructor. A custom errorClass now falls through to the two-argument form.
Author
|
Thanks @cloud-fan. I believe I addressed the feedback. Could you check again, please? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

What changes were proposed in this pull request?
Fix RaiseError.sql: [SPARK-55109] RaiseError(xyz).sql is broken in 4.0
Repro:
import org.apache.spark.sql.catalyst.expressions.{Literal, RaiseError}
println(RaiseError(Literal("error!")).sql)
3.5 generates valid SQL:
raise_error('error!')
4.0:
raise_error('USER_RAISED_EXCEPTION', map('errorMessage', 'error!'))
Why are the changes needed?
To fix the regression in 4.0
Does this PR introduce any user-facing change?
Bug fix, now it generates valid SQL.
How was this patch tested?
New unit test.
Was this patch authored or co-authored using generative AI tooling?
Generated-by: Github Copilot v1.0.14-0