-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-15445][SQL] Build fails for java 1.7 after adding java.mathBigInteger support #13223
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
…h.BigInteger support
|
cc: @srowen |
| this.decimalVal = null | ||
| this.longVal = bigintval.longValueExact() | ||
| // TODO: Remove this once we migrate to java8 and use longValueExact() instead. | ||
| val isExactLong = bigintval.compareTo(BigInteger.valueOf(JLong.MAX_VALUE)) <= 0 && |
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.
Maybe extract constants for a BigInteger representation of the max/min values rather than compute each time? Also is this all uses of java.util.Long that can be JLong?
| def toScalaBigInt: BigInt = BigInt(toLong) | ||
|
|
||
| def toJavaBigInteger: java.math.BigInteger = java.math.BigInteger.valueOf(toLong) | ||
| def toJavaBigInteger: BigInteger = BigInteger.valueOf(toLong) |
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.
Although I support removing the redundant qualified name, I wonder if we should also un-qualify scala.math.BigInt, or else leave both qualified even though they're not ambiguous. BigDecimal is used unqualified while the Java version is always qualified, to disambiguate. I guess it would become consistent if BigInt were not qualified.
|
Test build #58977 has finished for PR 13223 at commit
|
|
Test build #58978 has finished for PR 13223 at commit
|
|
Test build #58979 has finished for PR 13223 at commit
|
|
Test build #58980 has finished for PR 13223 at commit
|
|
Test build #58987 has finished for PR 13223 at commit
|
|
@srowen Comments addressed. |
|
cc @kevinyu98 |
|
@techaddict @srowen @cloud-fan @gatorsmile : Hi Sandeep , thanks for fixing this. I didn't realize the method is java 1.8 only. The code looks good to me. |
| case d: BigDecimal => apply(d) | ||
| case k: scala.math.BigInt => apply(k) | ||
| case l: java.math.BigInteger => apply(l) | ||
| case k: BigInt => apply(k) |
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.
this is too confusing. please keep the qualifiers. i'd actually keep qualifiers everywhere.
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.
The code is inconsistent in this regard though. I thought it worth cleaning up but don't feel strongly about it. Alternative is to qualify both classes everywhere consistently
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.
I agree it's better to make it consistent, but let's not mix it into a simple fix for java 7 ...
|
@techaddict thanks for doing this. Can you be more surgical in fixes like this? i.e. just fix the line that is causing problem. |
|
Also I think you can remove "HOTFIX" -- those are for master build breaking changes, which isn't happening here yet. (fwiw we don't run java 7 on master) |
| private[sql] val ZERO = Decimal(0) | ||
| private[sql] val ONE = Decimal(1) | ||
|
|
||
| private[types] val LONG_MAX_BIG_INT = BigInteger.valueOf(JLong.MAX_VALUE) |
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.
this can just be private
|
Test build #59022 has finished for PR 13223 at commit
|
|
Test build #59048 has finished for PR 13223 at commit
|
|
Merged to master/2.0 |
…Integer support ## What changes were proposed in this pull request? Using longValue() and then checking whether the value is in the range for a long manually. ## How was this patch tested? Existing tests Author: Sandeep Singh <[email protected]> Closes #13223 from techaddict/SPARK-15445. (cherry picked from commit 666bf2e) Signed-off-by: Sean Owen <[email protected]>
What changes were proposed in this pull request?
Using longValue() and then checking whether the value is in the range for a long manually.
How was this patch tested?
Existing tests