mingmwang commented on PR #6331:
URL:
https://github.com/apache/arrow-datafusion/pull/6331#issuecomment-1543398311
```spark
override def resultDecimalType(p1: Int, s1: Int, p2: Int, s2: Int):
DecimalType = {
val resultScale = s1 + s2
val resultPrecision = p1 + p2 + 1
if (allowPrecisionLoss) {
DecimalType.adjustPrecisionScale(resultPrecision, resultScale)
} else {
DecimalType.bounded(resultPrecision, resultScale)
}
}
private lazy val numeric = TypeUtils.getNumeric(dataType, failOnError)
protected override def nullSafeEval(input1: Any, input2: Any): Any =
dataType match {
case DecimalType.Fixed(precision, scale) =>
checkDecimalOverflow(numeric.times(input1,
input2).asInstanceOf[Decimal], precision, scale)
case _: IntegerType if failOnError =>
MathUtils.multiplyExact(
input1.asInstanceOf[Int],
input2.asInstanceOf[Int],
getContextOrNull())
case _: LongType if failOnError =>
MathUtils.multiplyExact(
input1.asInstanceOf[Long],
input2.asInstanceOf[Long],
getContextOrNull())
case _ => numeric.times(input1, input2)
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]