-
Notifications
You must be signed in to change notification settings - Fork 28.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SPARK-48035][SQL] Fix try_add/try_multiply being semantic equal to a…
…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 #46307 from db-scnakandala/db-scnakandala/master. Authored-by: Supun Nakandala <supun.nakandala@databricks.com> Signed-off-by: Hyukjin Kwon <gurwls223@apache.org>
- Loading branch information
1 parent
c94fe37
commit 7290000
Showing
3 changed files
with
53 additions
and
9 deletions.
There are no files selected for viewing
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
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
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