sathiyapk commented on a change in pull request #34729:
URL: https://github.com/apache/spark/pull/34729#discussion_r808321221
##########
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 sorry, it doesn't work. I still get a similar error.
org.codehaus.commons.compiler.CompileException: File 'generated.java', Line
55, Column 11: **No applicable constructor/method found for actual parameters
"java.math.BigDecimal"; candidates are: "org.apache.spark.sql.types.Decimal()"**
Here is the code:
```
val evaluationCode = dataType match {
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} = new Decimal(new java.math.BigDecimal(${ce.value}).
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]