-
Notifications
You must be signed in to change notification settings - Fork 28.3k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
[SPARK-49549][SQL] Assign a name to the error conditions _LEGACY_ERROR_TEMP_3055, 3146 #48288
Conversation
6de8c67
to
9c45cf9
Compare
@@ -182,7 +182,7 @@ object V2ExpressionUtils extends SQLConfHelper with Logging { | |||
ApplyFunctionExpression(scalarFunc, arguments) | |||
case _ => | |||
throw new AnalysisException( | |||
errorClass = "_LEGACY_ERROR_TEMP_3055", | |||
errorClass = "SCALAR_FUNCTION_NOT_FULLY_IMPLEMENTED", | |||
messageParameters = Map("scalarFunc" -> scalarFunc.name())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since scalarFunc.name
is an id, let's quote it by toSQLId()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replaced with
messageParameters = Map("scalarFunc" -> toSQLId(scalarFunc.name())))
}, | ||
"SCALAR_FUNCTION_NOT_FULLY_IMPLEMENTED" : { | ||
"message" : [ | ||
"ScalarFunction <scalarFunc> neither implements magic method nor override 'produceResult'" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should explicitly say what we expect: a method with the name produceResult
which accepts a parameter of the type InternalRow
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replaced with
"ScalarFunction <scalarFunc> not implements or overrides method 'produceResult(InternalRow)'."
@@ -3975,6 +3975,16 @@ | |||
], | |||
"sqlState" : "21000" | |||
}, | |||
"SCALAR_FUNCTION_NOT_COMPATIBLE" : { | |||
"message" : [ | |||
"Cannot find a compatible ScalarFunction#produceResult" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we suggest users how to fix the issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replaced with
"ScalarFunction <scalarFunc> not overrides method 'produceResult(InternalRow)' with custom implementation."
condition = "_LEGACY_ERROR_TEMP_3055", | ||
parameters = Map("scalarFunc" -> "long_add_mismatch_magic"), | ||
condition = "SCALAR_FUNCTION_NOT_FULLY_IMPLEMENTED", | ||
parameters = Map(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is no scalarFunc
parameter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed with
parameters = Map("scalarFunc" -> "`long_add_mismatch_magic`"),
513c953
to
943845a
Compare
@@ -149,7 +149,7 @@ public interface ScalarFunction<R> extends BoundFunction { | |||
* @return a result value | |||
*/ | |||
default R produceResult(InternalRow input) { | |||
throw new SparkUnsupportedOperationException("_LEGACY_ERROR_TEMP_3146"); | |||
throw new SparkUnsupportedOperationException("SCALAR_FUNCTION_NOT_COMPATIBLE"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error condition requires the parameter scalarFunc
. Could you pass it here, please.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed with
throw new SparkUnsupportedOperationException(
"SCALAR_FUNCTION_NOT_COMPATIBLE",
Map.of("scalarFunc", QuotingUtils.quoteIdentifier(name()))
);
I used QuotingUtils.quoteIdentifier
instead toSQLId
because this method is unavaible from this location.
943845a
to
9b10fe3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM except of a comment. Also update PR's description:
- remove the link to JIRA ticket
- error-classes.json -> error-conditions.json
"SCALAR_FUNCTION_NOT_COMPATIBLE", | ||
Map.of("scalarFunc", QuotingUtils.quoteIdentifier(name())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you fix indentation. Should be 2 gaps.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you fix indentation. Should be 2 gaps.
Fixed
LGTM except of a comment. Also update PR's description:
remove the link to JIRA ticket
error-classes.json -> error-conditions.json
Fixed
4ff4cf7
to
186c5bc
Compare
@mrk-andreev Could you fix the failed tests:
You should reformat
|
…R_TEMP_3055, 3146
186c5bc
to
bc1d202
Compare
Waiting for CI. @mrk-andreev Could you re-trigger the failed GitHub action: |
@MaxGekk fixed. |
+1, LGTM. Merging to master. |
…R_TEMP_3055, 3146 ### What changes were proposed in this pull request? Choose a proper name for the error conditions _LEGACY_ERROR_TEMP_3055 and _LEGACY_ERROR_TEMP_3146 defined in core/src/main/resources/error/error-conditions.json. The name should be short but complete (look at the example in error-conditions.json). Add a test which triggers the error from user code if such test still doesn't exist. Check exception fields by using checkError(). The last function checks valuable error fields only, and avoids dependencies from error text message. In this way, tech editors can modify error format in error-conditions.json, and don't worry of Spark's internal tests. Migrate other tests that might trigger the error onto checkError(). ### Why are the changes needed? This changes needed because spark 4 introduce new approach with user friendly error messages. ### Does this PR introduce _any_ user-facing change? Yes, if user's code depends on error condition names. ### How was this patch tested? Unit tests ### Was this patch authored or co-authored using generative AI tooling? No Closes apache#48288 from mrk-andreev/SPARK-49549. Authored-by: Mark Andreev <mark.andreev@gmail.com> Signed-off-by: Max Gekk <max.gekk@gmail.com>
What changes were proposed in this pull request?
Choose a proper name for the error conditions _LEGACY_ERROR_TEMP_3055 and _LEGACY_ERROR_TEMP_3146 defined in core/src/main/resources/error/error-conditions.json. The name should be short but complete (look at the example in error-conditions.json).
Add a test which triggers the error from user code if such test still doesn't exist. Check exception fields by using checkError(). The last function checks valuable error fields only, and avoids dependencies from error text message. In this way, tech editors can modify error format in error-conditions.json, and don't worry of Spark's internal tests. Migrate other tests that might trigger the error onto checkError().
Why are the changes needed?
This changes needed because spark 4 introduce new approach with user friendly error messages.
Does this PR introduce any user-facing change?
Yes, if user's code depends on error condition names.
How was this patch tested?
Unit tests
Was this patch authored or co-authored using generative AI tooling?
No