-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-31761][SQL] cast integer to Long to avoid IntegerOverflow for IntegralDivide operator #28600
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
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/arithmetic.scala
Outdated
Show resolved
Hide resolved
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/arithmetic.scala
Outdated
Show resolved
Hide resolved
...yst/src/test/scala/org/apache/spark/sql/catalyst/expressions/ArithmeticExpressionSuite.scala
Outdated
Show resolved
Hide resolved
|
Test build #122943 has finished for PR 28600 at commit
|
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/arithmetic.scala
Outdated
Show resolved
Hide resolved
Handled cast in TypeCoercion
|
Test build #122969 has finished for PR 28600 at commit
|
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/TypeCoercion.scala
Outdated
Show resolved
Hide resolved
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/TypeCoercion.scala
Outdated
Show resolved
Hide resolved
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/TypeCoercion.scala
Outdated
Show resolved
Hide resolved
sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala
Outdated
Show resolved
Hide resolved
88d70bd to
7cdc7b5
Compare
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/TypeCoercion.scala
Show resolved
Hide resolved
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/TypeCoercion.scala
Outdated
Show resolved
Hide resolved
|
Test build #122979 has finished for PR 28600 at commit
|
|
Test build #122982 has finished for PR 28600 at commit
|
|
there is a failure in |
|
this is because I changed the acceptedType to Long and Decimal
from the test case shall I remove checkEvaluation for byte,short and int ? |
|
Test build #122988 has finished for PR 28600 at commit
|
|
Test build #122992 has finished for PR 28600 at commit
|
Yes please |
OK so the problem here is we change the auto-generated column name of It's not a big deal, we can just update all the tests. But I'm thinking if it's better to embed the cast in the This is probably more efficient as there are less expressions |
this was my first approach, now I am updating the golden files. Let me know which way we need to do, accordingly I will update the code |
… for DIV operator
|
Test build #123005 has finished for PR 28600 at commit
|
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/TypeCoercion.scala
Show resolved
Hide resolved
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/TypeCoercion.scala
Outdated
Show resolved
Hide resolved
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/TypeCoercion.scala
Outdated
Show resolved
Hide resolved
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/TypeCoercion.scala
Outdated
Show resolved
Hide resolved
sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala
Outdated
Show resolved
Hide resolved
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/analysis/TypeCoercionSuite.scala
Show resolved
Hide resolved
maropu
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.
LGTM if the tests passed.
|
Test build #123026 has finished for PR 28600 at commit
|
|
retest this please |
|
Test build #123029 has finished for PR 28600 at commit
|
HyukjinKwon
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.
LGTM too
|
Merged to master. @sandeep-katta, it has a conflict against branch-3.0. Although it's minor, can you create a PR to backport it? Looks like these SQL files have some diff in the tests results lately. Let's just create a PR to backport just to doubly make sure. |
|
okay will raise BackPort PR |
…IntegralDivide operator `IntegralDivide` operator returns Long DataType, so integer overflow case should be handled. If the operands are of type Int it will be casted to Long As `IntegralDivide` returns Long datatype, integer overflow should not happen No Added UT and also tested in the local cluster After fix  SQL Test After fix  Before Fix  Closes apache#28600 from sandeep-katta/integerOverFlow. Authored-by: sandeep katta <[email protected]> Signed-off-by: HyukjinKwon <[email protected]>
What changes were proposed in this pull request?
IntegralDivideoperator returns Long DataType, so integer overflow case should be handled.If the operands are of type Int it will be casted to Long
Why are the changes needed?
As
IntegralDividereturns Long datatype, integer overflow should not happenDoes this PR introduce any user-facing change?
No
How was this patch tested?
Added UT and also tested in the local cluster
After fix
SQL Test
After fix

Before Fix
