sathiyapk commented on a change in pull request #34729:
URL: https://github.com/apache/spark/pull/34729#discussion_r809401956
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/mathExpressions.scala
##########
@@ -1426,12 +1526,21 @@ abstract class RoundBase(child: Expression, scale:
Expression,
val ce = child.genCode(ctx)
val evaluationCode = dataType match {
- case DecimalType.Fixed(_, s) =>
- s"""
- |${ev.value} = ${ce.value}.toPrecision(${ce.value}.precision(), $s,
- | Decimal.$modeStr(), true);
- |${ev.isNull} = ${ev.value} == null;
- """.stripMargin
+ case DecimalType.Fixed(p, s) =>
+ if (_scale >= 0) {
+ s"""
+ ${ev.value} = ${ce.value}.toPrecision(${ce.value}.precision(), $s,
+ Decimal.$modeStr(), true);
+ ${ev.isNull} = ${ev.value} == null;"""
+ } else {
+ s"""
+ ${ev.value} = ${ce.value}.toPrecision(${ce.value}.precision(), $s,
+ Decimal.$modeStr(), true);
+ ${ev.isNull} = ${ev.value} == null;"""
+// s"""
+// ${ev.value} = new java.math.BigDecimal(${ce.value}).
+// setScale(${_scale}, java.math.BigDecimal.${modeStr});"""
Review comment:
@cloud-fan I get the following error:
org.codehaus.commons.compiler.CompileException: File 'generated.java', Line
56, Column 2: **"toJavaBigDecimal" is neither a method, a field, nor a member
class of "org.apache.spark.sql.types.Decimal"**
```
s"""
${ev.value} = new Decimal(${ce.value}.toJavaBigDecimal
.setScale(${_scale}, java.math.BigDecimal.${modeStr}));"""
```
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]