[SPARK-57750][SQL] Assign a name to the error condition _LEGACY_ERROR_TEMP_3084 and set its cause#56867
Open
MaxGekk wants to merge 2 commits into
Open
[SPARK-57750][SQL] Assign a name to the error condition _LEGACY_ERROR_TEMP_3084 and set its cause#56867MaxGekk wants to merge 2 commits into
MaxGekk wants to merge 2 commits into
Conversation
…_TEMP_3084 and set its cause ### What changes were proposed in this pull request? Replace the legacy error condition `_LEGACY_ERROR_TEMP_3084`, raised when a Hive UDF/UDAF/UDTF wrapper class fails to instantiate during function resolution, with the descriptive condition `CANNOT_INSTANTIATE_HIVE_FUNCTION`, and attach the original failure as the exception cause. - Add `CANNOT_INSTANTIATE_HIVE_FUNCTION` (SQLSTATE 38000) to error-conditions.json and remove `_LEGACY_ERROR_TEMP_3084`. - Add `QueryCompilationErrors.cannotInstantiateHiveFunctionError(clazz, e)` that passes `cause = Some(e)` so the inner failure is preserved on the exception chain. - Update `HiveSessionStateBuilder.makeHiveFunctionExpression` to throw the new error and drop the manual `setStackTrace` (the cause now carries the inner stack trace). - Update `HiveUDFSuite` to assert via `checkError` on the new condition, and to read the inner failure via `getCause` where the wrapped message was previously asserted. ### Why are the changes needed? Part of the error-class migration (umbrella SPARK-37935). The legacy condition used a free-form `e` message parameter and did not attach the cause (`getCause` returned null), so callers and tests could not programmatically unwrap the inner failure. ### Does this PR introduce _any_ user-facing change? Yes. The error condition name and message change, and the original exception is now attached as the cause. Within the unreleased master branch only. ### How was this patch tested? By running: - `build/sbt "core/testOnly org.apache.spark.SparkThrowableSuite"` - `build/sbt "hive/testOnly org.apache.spark.sql.hive.execution.HiveUDFSuite"` ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Cursor
dongjoon-hyun
approved these changes
Jun 29, 2026
…ched cause Follow-up: use checkError on the inner AnalysisException (the now-attached cause) for the raw/wildcard collection cases in HiveUDFSuite, and read the inner Hive SemanticException message via getCause in UDFSuite (SPARK-21318), which previously relied on the inner failure being embedded in the wrapper exception's message.
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?
Replace the legacy error condition
_LEGACY_ERROR_TEMP_3084, raised when a Hive UDF/UDAF/UDTF wrapper class fails to instantiate during function resolution, with the descriptive conditionCANNOT_INSTANTIATE_HIVE_FUNCTION, and attach the original failure as the exception cause.CANNOT_INSTANTIATE_HIVE_FUNCTION(SQLSTATE38000) toerror-conditions.jsonand remove_LEGACY_ERROR_TEMP_3084.QueryCompilationErrors.cannotInstantiateHiveFunctionError(clazz, e)that passescause = Some(e)so the inner failure is preserved on the exception chain.HiveSessionStateBuilder.makeHiveFunctionExpressionto throw the new error and drop the manualsetStackTrace(the attached cause now carries the inner stack trace).HiveUDFSuiteto assert viacheckErroron the new condition, and to read the inner failure viagetCausewhere the wrapped message was previously asserted.Why are the changes needed?
Part of the error-class migration (umbrella SPARK-37935). The legacy condition used a free-form
emessage parameter and did not attach the cause: the 2-argAnalysisException(errorClass, messageParameters)constructor setscause = None, sogetCausereturnednulland callers/tests could not programmatically unwrap the inner failure (for example, asserting the inner condition viacheckError).Does this PR introduce any user-facing change?
Yes. The error condition name and message change, and the original exception is now attached as the cause. This is a change within the unreleased
masterbranch only.Before:
After:
How was this patch tested?
By running:
build/sbt "core/testOnly org.apache.spark.SparkThrowableSuite"build/sbt "hive/testOnly org.apache.spark.sql.hive.execution.HiveUDFSuite"Was this patch authored or co-authored using generative AI tooling?
Generated-by: Cursor