-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-28369][SQL] Honor spark.sql.decimalOperations.nullOnOverflow in ScalaUDF result #25144
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 |
|---|---|---|
|
|
@@ -414,20 +414,12 @@ final class Decimal extends Ordered[Decimal] with Serializable { | |
|
|
||
| def floor: Decimal = if (scale == 0) this else { | ||
| val newPrecision = DecimalType.bounded(precision - scale + 1, 0).precision | ||
| val res = toPrecision(newPrecision, 0, ROUND_FLOOR) | ||
| if (res == null) { | ||
| throw new AnalysisException(s"Overflow when setting precision to $newPrecision") | ||
| } | ||
| res | ||
| toPrecision(newPrecision, 0, ROUND_FLOOR, nullOnOverflow = false) | ||
| } | ||
|
|
||
| def ceil: Decimal = if (scale == 0) this else { | ||
| val newPrecision = DecimalType.bounded(precision - scale + 1, 0).precision | ||
| val res = toPrecision(newPrecision, 0, ROUND_CEILING) | ||
| if (res == null) { | ||
| throw new AnalysisException(s"Overflow when setting precision to $newPrecision") | ||
| } | ||
| res | ||
| toPrecision(newPrecision, 0, ROUND_CEILING, nullOnOverflow = false) | ||
|
Member
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. This throws exception on overflow, I think it preserves current behavior, but don't we want to respect
Contributor
Author
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. well, I don't think that is really an issue here. I mean, I see no way ceil and floor can produce an overflow, they rather reduce the needed precision. So I think this case cannot really happen and it is fine to just throw an exception |
||
| } | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.