-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-40748][SQL] Migrate type check failures of conditions onto error classes #38438
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
|
Can one of the admins verify this patch? |
|
@panbingkun Could you resolve conflicts, please. |
| .forEach(s -> | ||
| Assert.assertTrue(e.getMessage().toLowerCase(Locale.ROOT) | ||
| .contains(s.toLowerCase(Locale.ROOT)))); | ||
| System.out.println(e.getMessage().toLowerCase(Locale.ROOT)); |
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.
Is it needed?
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.
Sorry, I left the debugging code by mistake.
| Arrays.asList( | ||
| "datatype_mismatch.data_diff_types", | ||
| "cannot resolve \"(a in (b))\"", | ||
| "due to data type mismatch: input to `in` should all be the same type, " + | ||
| "but it's [\"int\", \"array<int>\"].").forEach(s -> | ||
| Assert.assertTrue(e.getMessage().toLowerCase(Locale.ROOT) | ||
| .contains(s.toLowerCase(Locale.ROOT)))); |
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.
Let's don't compare error messages. If you cannot call checkError() easily, just check error classes (maybe more if you can).
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 will check:
1.Exception Type -> AnalysisException
2.Error classes.
| .forEach(s -> | ||
| Assert.assertTrue(e.getMessage().toLowerCase(Locale.ROOT) | ||
| .contains(s.toLowerCase(Locale.ROOT)))); | ||
| Assert.assertTrue(e.message().startsWith("[DATATYPE_MISMATCH.DATA_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.
e is an AnalysisException, correct? Can't you just check its errorClass?
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.
MaxGekk
left a comment
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.
Waiting for CI. @panbingkun Please, re-trigger GAs.
| .contains(s.toLowerCase(Locale.ROOT)))); | ||
| Assert.assertTrue(e.getErrorClass().equals("DATATYPE_MISMATCH.DATA_DIFF_TYPES")); | ||
| Map<String, String> messageParameters = new HashMap() { | ||
| { |
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.
Just in case, are the inner {} really needed?
|
+1, LGTM. Merging to master. |
…or classes ### What changes were proposed in this pull request? This pr replaces TypeCheckFailure by DataTypeMismatch in type checks in the conditional expressions, includes: 1. If (2): https://github.com/apache/spark/blob/1431975723d8df30a25b2333eddcfd0bb6c57677/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/conditionalExpressions.scala#L61-L67 2. CaseWhen (2): https://github.com/apache/spark/blob/1431975723d8df30a25b2333eddcfd0bb6c57677/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/conditionalExpressions.scala#L175-L183 3. InSubquery (2): https://github.com/apache/spark/blob/1431975723d8df30a25b2333eddcfd0bb6c57677/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/predicates.scala#L378-L396 4. In (1): https://github.com/apache/spark/blob/1431975723d8df30a25b2333eddcfd0bb6c57677/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/predicates.scala#L453 ### 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#38438 from panbingkun/SPARK-40748. 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 conditional expressions, includes:
spark/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/conditionalExpressions.scala
Lines 61 to 67 in 1431975
spark/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/conditionalExpressions.scala
Lines 175 to 183 in 1431975
spark/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/predicates.scala
Lines 378 to 396 in 1431975
spark/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/predicates.scala
Line 453 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?