[CALCITE-5640] Add SAFE_ADD function (enabled in BigQuery library) - #3370
Merged
Conversation
tanclary
force-pushed
the
safe-add
branch
3 times, most recently
from
August 16, 2023 16:34
ca2bb36 to
9946240
Compare
|
|
||
| /** SQL <code>SAFE_ADD</code> function applied to BigDecimal and long values. */ | ||
| public static @Nullable BigDecimal safeAdd(BigDecimal b0, long b1) { | ||
| BigDecimal ans = b0.add(BigDecimal.valueOf(b1)); |
Contributor
There was a problem hiding this comment.
I believe using return safeAdd(b1, b0) would be better.
Same comment for
Double safeAdd(long b0, double b1)
Double safeAdd(BigDecimal b0, double b1)
Contributor
Author
There was a problem hiding this comment.
This is a great suggestion. I have updated the methods for safeAdd and safeMultiply as well. Let me know if you have any other thoughts, thanks!
|
Kudos, SonarCloud Quality Gate passed! |
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.








This PR continues working towards the goal of implementing all BigQuery safe arithmetic functions, captured in CALCITE-5591. SAFE_MULTIPLY was merged recently in 1b8dc6 and this PR follows a very similar structure, except of course using addition rather than multiplication.
Any questions or suggestions would be appreciated as always!