-
Notifications
You must be signed in to change notification settings - Fork 28.7k
[SPARK-28201][SQL] Revisit MakeDecimal behavior on overflow #25010
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,7 +76,7 @@ final class Decimal extends Ordered[Decimal] with Serializable { | |
*/ | ||
def set(unscaled: Long, precision: Int, scale: Int): Decimal = { | ||
if (setOrNull(unscaled, precision, scale) == null) { | ||
throw new IllegalArgumentException("Unscaled value too large for precision") | ||
throw new ArithmeticException("Unscaled value too large for precision") | ||
} | ||
this | ||
} | ||
|
@@ -111,9 +111,10 @@ final class Decimal extends Ordered[Decimal] with Serializable { | |
*/ | ||
def set(decimal: BigDecimal, precision: Int, scale: Int): Decimal = { | ||
this.decimalVal = decimal.setScale(scale, ROUND_HALF_UP) | ||
require( | ||
decimalVal.precision <= precision, | ||
s"Decimal precision ${decimalVal.precision} exceeds max precision $precision") | ||
if (decimalVal.precision > precision) { | ||
throw new ArithmeticException( | ||
s"Decimal precision ${decimalVal.precision} exceeds max precision $precision") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi, All. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I made #25165 . There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks @dongjoon-hyun , sorry for the trouble. I hadn't run integration tests indeed. |
||
} | ||
this.longVal = 0L | ||
this._precision = precision | ||
this._scale = scale | ||
|
Uh oh!
There was an error while loading. Please reload this page.