-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-40374][SQL] Migrate type check failures of type creators onto error classes #38463
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
| "To convert values from <srcType> to <targetType>, you can use the functions <functionNames> instead." | ||
| ] | ||
| }, | ||
| "CREATE_MAP_KEY_DIFF_TYPES" : { |
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.
Cloud we make DATA_DIFF_TYPES more general and reuse it?
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 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 given keys of function <functionName> should all be the same type, but they are <dataType>." | ||
| ] | ||
| }, | ||
| "CREATE_MAP_VALUE_DIFF_TYPES" : { |
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.
ditto
| s"Only foldable ${StringType.catalogString} expressions are allowed to appear at odd" + | ||
| s" position, got: ${invalidNames.mkString(",")}") | ||
| DataTypeMismatch( | ||
| errorSubClass = "CREATE_NAMED_STRUCT_WITHOUT_FOLDABLE_STRING", |
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 NON_FOLDABLE_INPUT be reused?
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 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.
It seems that would be hard to make NON_FOLDABLE_INPUT more general to cover the case. Let's introduce more specific error class for the case.
| ) | ||
| } else if (newExprs.isEmpty) { | ||
| TypeCheckResult.TypeCheckFailure("cannot drop all fields in struct") | ||
| DataTypeMismatch( |
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.
It seems that the original message did not clearly describe this error, the message doesn't look like DataTypeMismatch
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.
It is some kind of UNEXPECTED_INPUT_TYPE: op (drop field) + its args are not supported because they produce empty struct. I am ok w/ this particular error class.
|
Can one of the admins verify this patch? |
|
cc @MaxGekk |
|
+1, LGTM. Merging to master. |
…error classes ### What changes were proposed in this pull request? This pr replaces TypeCheckFailure by DataTypeMismatch in type checks in the complex type creator expressions, includes: 1. CreateMap (3): https://github.com/apache/spark/blob/1431975723d8df30a25b2333eddcfd0bb6c57677/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/complexTypeCreator.scala#L205-L214 2. CreateNamedStruct (3): https://github.com/apache/spark/blob/1431975723d8df30a25b2333eddcfd0bb6c57677/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/complexTypeCreator.scala#L445-L457 3. UpdateFields (2): https://github.com/apache/spark/blob/1431975723d8df30a25b2333eddcfd0bb6c57677/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/complexTypeCreator.scala#L670-L673 ### Why are the changes needed? Migration onto error classes unifies Spark SQL error messages. ### Does this PR introduce _any_ user-facing change? Yes. The PR changes user-facing error messages. ### How was this patch tested? 1. Add new UT 2. Update existed UT 3. Pass GA Closes apache#38463 from panbingkun/SPARK-40374. Authored-by: panbingkun <[email protected]> Signed-off-by: Max Gekk <[email protected]>



What changes were proposed in this pull request?
This pr replaces TypeCheckFailure by DataTypeMismatch in type checks in the complex type creator expressions, includes:
spark/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/complexTypeCreator.scala
Lines 205 to 214 in 1431975
spark/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/complexTypeCreator.scala
Lines 445 to 457 in 1431975
spark/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/complexTypeCreator.scala
Lines 670 to 673 in 1431975
Why are the changes needed?
Migration onto error classes unifies Spark SQL error messages.
Does this PR introduce any user-facing change?
Yes. The PR changes user-facing error messages.
How was this patch tested?