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
[SPARK-48035][SQL] Fix try_add/try_multiply being semantic equal to add/multiply #46307
Closed
db-scnakandala
wants to merge
2
commits into
apache:master
from
db-scnakandala:db-scnakandala/master
Closed
[SPARK-48035][SQL] Fix try_add/try_multiply being semantic equal to add/multiply #46307
db-scnakandala
wants to merge
2
commits into
apache:master
from
db-scnakandala:db-scnakandala/master
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
db-scnakandala
force-pushed
the
db-scnakandala/master
branch
2 times, most recently
from
April 30, 2024 18:47
87e0dfa
to
c2a2edd
Compare
db-scnakandala
force-pushed
the
db-scnakandala/master
branch
from
April 30, 2024 20:05
c2a2edd
to
5a64cec
Compare
db-scnakandala
changed the title
[SPARK-48035] Fix try_add/try_multiply being semantic equal to add/multiply
[SPARK-48035][SQL] Fix try_add/try_multiply being semantic equal to add/multiply
May 1, 2024
cc: @cloud-fan |
HyukjinKwon
reviewed
May 1, 2024
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/CanonicalizeSuite.scala
Outdated
Show resolved
Hide resolved
…essions/CanonicalizeSuite.scala Co-authored-by: Hyukjin Kwon <[email protected]>
HyukjinKwon
approved these changes
May 7, 2024
Merged to master. |
cloud-fan
reviewed
May 7, 2024
// TODO: do not reorder consecutive `Add`s with different `evalMode` | ||
val reorderResult = buildCanonicalizedPlan( | ||
val evalModes = collectEvalModes(this, {case Add(_, _, evalMode) => Seq(evalMode)}) | ||
lazy val reorderResult = buildCanonicalizedPlan( | ||
{ case Add(l, r, _) => Seq(l, r) }, |
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.
shall we simply add check here? case Add(l, r, em) if em == evalMode
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.
That is neat! I will create a follow-up PR.
dongjoon-hyun
pushed a commit
that referenced
this pull request
May 7, 2024
…equal to add/multiply ### What changes were proposed in this pull request? - This is a follow-up to the previous PR: #46307. - With the new changes we do the evalMode check in the `collectOperands` function instead of introducing a new function. ### Why are the changes needed? - Better code quality and readability. ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? - Existing unit tests. ### Was this patch authored or co-authored using generative AI tooling? - No Closes #46414 from db-scnakandala/db-scnakandala/master. Authored-by: Supun Nakandala <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]>
JacobZheng0927
pushed a commit
to JacobZheng0927/spark
that referenced
this pull request
May 11, 2024
…dd/multiply ### What changes were proposed in this pull request? - This PR fixes a correctness bug in commutative operator canonicalization where we currently do not take into account the evaluation mode during operand reordering. - As a result, the following condition will be incorrectly true: ``` val l1 = Literal(1) val l2 = Literal(2) val l3 = Literal(3) val expr1 = Add(Add(l1, l2), l3) val expr2 = Add(Add(l2, l1, EvalMode.TRY), l3) expr1.semanticEquals(expr2) ``` - To fix the issue, we now reorder commutative operands only if all operators have the same evaluation mode. ### Why are the changes needed? - To fix a correctness bug. ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? - Added unit tests ### Was this patch authored or co-authored using generative AI tooling? No Closes apache#46307 from db-scnakandala/db-scnakandala/master. Authored-by: Supun Nakandala <[email protected]> Signed-off-by: Hyukjin Kwon <[email protected]>
JacobZheng0927
pushed a commit
to JacobZheng0927/spark
that referenced
this pull request
May 11, 2024
…equal to add/multiply ### What changes were proposed in this pull request? - This is a follow-up to the previous PR: apache#46307. - With the new changes we do the evalMode check in the `collectOperands` function instead of introducing a new function. ### Why are the changes needed? - Better code quality and readability. ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? - Existing unit tests. ### Was this patch authored or co-authored using generative AI tooling? - No Closes apache#46414 from db-scnakandala/db-scnakandala/master. Authored-by: Supun Nakandala <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
Why are the changes needed?
Does this PR introduce any user-facing change?
No
How was this patch tested?
Was this patch authored or co-authored using generative AI tooling?
No