Github user tejasapatil commented on a diff in the pull request:
https://github.com/apache/spark/pull/17075#discussion_r103598023
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/types/Decimal.scala ---
@@ -362,17 +374,13 @@ final class Decimal extends Ordered[Decimal] with
Serializable {
def abs: Decimal = if (this.compare(Decimal.ZERO) < 0) this.unary_- else
this
def floor: Decimal = if (scale == 0) this else {
- val value = this.clone()
- value.changePrecision(
- DecimalType.bounded(precision - scale + 1, 0).precision, 0,
ROUND_FLOOR)
- value
+ toPrecision(DecimalType.bounded(precision - scale + 1, 0).precision,
0, ROUND_FLOOR)
+ .getOrElse(clone())
--- End diff --
This might end up creating two copies of the object in worst case :
- once in `toPrecision`
- second time on this line
Old logic would guarantee a single copy.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]