Repository navigation
fix: [branch-1.2] preserve TRY overflow semantics in nested integer arithmetic (#7379) - #7652
Merged
Merged
Conversation
…ache#7379) * fix: preserve TRY overflow semantics in nested integer arithmetic * docs: explain evaluation mode boundaries in arithmetic chains (cherry picked from commit 268ede5)
This file contains hidden or 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
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.
Which issue does this PR close?
Backport of #7379 to
branch-1.2. Closes #7378 on this branch.Rationale for this change
With ANSI mode disabled, Spark returns
NULLfortry_add(a, b) + bwhen the inner addition overflows.branch-1.2flattens both additions into one balanced tree that uses the outer operation's wrapping overflow behavior, so it returns a wrapped integer instead. The same problem affectstry_multiplyinside a multiplication. See #7379 and #7378 for the full analysis.What changes are included in this PR?
Cherry-pick of 268ede5 (
git cherry-pick -x) with no conflicts and no adaptations. Flattening inCometAddandCometMultiplynow stops at a nestedAddorMultiplywhoseevalModediffers from the outer one, and the source PR'sarithmetic.sqlcase is included. The diff against the source commit is identical apart from line numbers and blob hashes.Other release branches:
branch-1.2is the newest release branch, so there is no newer one to port to.How are these changes tested?
On this branch, with JDK 17 and the default Spark profile only:
CometSqlFileTestSuiteforarithmetic.sql,arithmetic_ansi.sqlandarithmetic_try.sqlpasses against a native library built from this branch (3 tests, 0 failures). Witharithmetic.scalarestored tobranch-1.2's version,arithmetic.sqlfails (the other two still pass), so the branch has the bug and the test catches it.