Skip to content

Commit cfda7e4

Browse files
committed
Revert "[SPARK-8677] [SQL] Fix non-terminating decimal expansion for decimal divide operation"
This reverts commit 24fda73.
1 parent 2de9afe commit cfda7e4

File tree

2 files changed

+2
-14
lines changed

2 files changed

+2
-14
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/types/Decimal.scala

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -265,15 +265,8 @@ final class Decimal extends Ordered[Decimal] with Serializable {
265265

266266
def * (that: Decimal): Decimal = Decimal(toBigDecimal * that.toBigDecimal)
267267

268-
def / (that: Decimal): Decimal = {
269-
if (that.isZero) {
270-
null
271-
} else {
272-
// To avoid non-terminating decimal expansion problem, we turn to Java BigDecimal's divide
273-
// with specified ROUNDING_MODE.
274-
Decimal(toJavaBigDecimal.divide(that.toJavaBigDecimal, ROUNDING_MODE.id))
275-
}
276-
}
268+
def / (that: Decimal): Decimal =
269+
if (that.isZero) null else Decimal(toBigDecimal / that.toBigDecimal)
277270

278271
def % (that: Decimal): Decimal =
279272
if (that.isZero) null else Decimal(toBigDecimal % that.toBigDecimal)

sql/catalyst/src/test/scala/org/apache/spark/sql/types/decimal/DecimalSuite.scala

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,4 @@ class DecimalSuite extends SparkFunSuite with PrivateMethodTester {
176176
val decimal = (Decimal(Long.MaxValue, 38, 0) * Decimal(Long.MaxValue, 38, 0)).toJavaBigDecimal
177177
assert(decimal.unscaledValue.toString === "85070591730234615847396907784232501249")
178178
}
179-
180-
test("fix non-terminating decimal expansion problem") {
181-
val decimal = Decimal(1.0, 10, 3) / Decimal(3.0, 10, 3)
182-
assert(decimal.toString === "0.333")
183-
}
184179
}

0 commit comments

Comments
 (0)