-
Notifications
You must be signed in to change notification settings - Fork 28.6k
[SPARK-39255][SQL] Improve error messages #36635
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
The test failure:
is not related to the PR, I believe. @gengliangwang @HyukjinKwon @cloud-fan Could you have a look at this, please. |
@@ -23,7 +23,7 @@ | |||
"message" : [ "Cannot up cast <value> from <sourceType> to <targetType>.\n<details>" ] | |||
}, | |||
"CAST_INVALID_INPUT" : { | |||
"message" : [ "The value <value> of the type <sourceType> cannot be cast to <targetType> because it is malformed. To return NULL instead, use `try_cast`. If necessary set <config> to \"false\" to bypass this error." ], | |||
"message" : [ "The value <value> of the type <sourceType> cannot be cast to <targetType> because it is malformed. Correct the syntax for the value before casting it, or change the type to one appropriate for the value. To return NULL instead, use `try_cast`. If necessary set <config> to \"false\" to bypass this error." ], |
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.
What do you mean by "Correct the syntax for the value"? Do you mean "Correct the values as per the syntax"?
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.
nit: "change the type to one appropriate for the value" => "change an appropriate type for the value"?
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.
Do you mean "Correct the values as per the syntax"?
Yep
nit: "change the type to one appropriate for the value" => "change an appropriate type for the value"?
Maybe just, "change the target type"?
How about:
Correct the value as per the syntax, or change its target type.
?
@@ -48,13 +48,13 @@ | |||
"FAILED_EXECUTE_UDF" : { | |||
"message" : [ "Failed to execute user defined function (<functionName>: (<signature>) => <result>)" ] | |||
}, | |||
"FAILED_PERMISSION_RESET_ORIGINAL" : { |
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.
How about FAILED_TO_SET_ORIGINAL_PERMISSION_BACK
?
I didn't follow the error message improvement project closely. Do we have a naming pattern?
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.
Do we have a naming pattern?
no, we don't as far as I know.
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.
How about FAILED_TO_SET_ORIGINAL_PERMISSION_BACK?
It would be nice to have shorter names for error classes since we are going to use them as tags in docs headers.
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.
Yeah, it's hard to come up with a pattern that really works.
Some thought:
- The error class is typically followed by the message. No need for a sentence.. That's what the message does.
- Short is beautiful
- Try to avoid stating that an error is an error in the name.. provides no new information. It's an error class! ;-)
How about
RESET_PERMISSION_TO_ORIGINAL
(again we KNOW it's failed)
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.
SET_PERMISSION_BACK is shorter than RESET_PERMISSION_TO_ORIGINAL ;-)
LGTM except some minor comments. Thanks for the work! |
cc @srielau |
Co-authored-by: Gengliang Wang <ltnwgl@gmail.com>
Merging to master. Thank you, @gengliangwang and @cloud-fan @srielau for review. |
In the PR, I propose to improve errors of the following error classes: 1. NON_PARTITION_COLUMN - `a non-partition column name` -> `the non-partition column` 2. UNSUPPORTED_SAVE_MODE - `a not existent path` -> `a non existent path`. 3. INVALID_FIELD_NAME. Quote ids to follow the rules apache#36621. 4. FAILED_SET_ORIGINAL_PERMISSION_BACK. It is renamed to FAILED_PERMISSION_RESET_ORIGINAL. 5. NON_LITERAL_PIVOT_VALUES - Wrap error's expression by double quotes. The PR adds new helper method `toSQLExpr()` for that. 6. CAST_INVALID_INPUT - Add the recommendation: `... Correct the syntax for the value before casting it, or change the type to one appropriate for the value.` To improve user experience with Spark SQL by making error message more clear. Yes, it changes user-facing error messages. By running the affected test suites: ``` $ build/sbt "sql/testOnly org.apache.spark.sql.SQLQueryTestSuite" $ build/sbt "sql/testOnly *QueryCompilationErrorsDSv2Suite" $ build/sbt "sql/testOnly *QueryCompilationErrorsSuite" $ build/sbt "sql/testOnly *QueryExecutionAnsiErrorsSuite" $ build/sbt "sql/testOnly *QueryExecutionErrorsSuite" $ build/sbt "sql/testOnly *QueryParsingErrorsSuite*" ``` Closes apache#36635 from MaxGekk/error-class-improve-msg-3. Lead-authored-by: Max Gekk <max.gekk@gmail.com> Co-authored-by: Maxim Gekk <max.gekk@gmail.com> Signed-off-by: Max Gekk <max.gekk@gmail.com> (cherry picked from commit 625afb4) Signed-off-by: Max Gekk <max.gekk@gmail.com>
### What changes were proposed in this pull request? In the PR, I propose to improve errors of the following error classes: 1. NON_PARTITION_COLUMN - `a non-partition column name` -> `the non-partition column` 2. UNSUPPORTED_SAVE_MODE - `a not existent path` -> `a non existent path`. 3. INVALID_FIELD_NAME. Quote ids to follow the rules #36621. 4. FAILED_SET_ORIGINAL_PERMISSION_BACK. It is renamed to RESET_PERMISSION_TO_ORIGINAL. 5. NON_LITERAL_PIVOT_VALUES - Wrap error's expression by double quotes. The PR adds new helper method `toSQLExpr()` for that. 6. CAST_INVALID_INPUT - Add the recommendation: `... Correct the syntax for the value before casting it, or change the type to one appropriate for the value.` This is a backport of #36635. ### Why are the changes needed? To improve user experience with Spark SQL by making error message more clear. ### Does this PR introduce _any_ user-facing change? Yes, it changes user-facing error messages. ### How was this patch tested? By running the affected test suites: ``` $ build/sbt "sql/testOnly org.apache.spark.sql.SQLQueryTestSuite" $ build/sbt "sql/testOnly *QueryCompilationErrorsDSv2Suite" $ build/sbt "sql/testOnly *QueryCompilationErrorsSuite" $ build/sbt "sql/testOnly *QueryExecutionAnsiErrorsSuite" $ build/sbt "sql/testOnly *QueryExecutionErrorsSuite" $ build/sbt "sql/testOnly *QueryParsingErrorsSuite*" ``` Lead-authored-by: Max Gekk <max.gekkgmail.com> Co-authored-by: Maxim Gekk <max.gekkgmail.com> Signed-off-by: Max Gekk <max.gekkgmail.com> (cherry picked from commit 625afb4) Signed-off-by: Max Gekk <max.gekkgmail.com> Closes #36655 from MaxGekk/error-class-improve-msg-3-3.3. Authored-by: Max Gekk <max.gekk@gmail.com> Signed-off-by: Max Gekk <max.gekk@gmail.com>
What changes were proposed in this pull request?
In the PR, I propose to improve errors of the following error classes:
a non-partition column name
->the non-partition column
a not existent path
->a non existent path
.toSQLExpr()
for that.... Correct the syntax for the value before casting it, or change the type to one appropriate for the value.
Why are the changes needed?
To improve user experience with Spark SQL by making error message more clear.
Does this PR introduce any user-facing change?
Yes, it changes user-facing error messages.
How was this patch tested?
By running the affected test suites: