gengliangwang commented on code in PR #56921:
URL: https://github.com/apache/spark/pull/56921#discussion_r3539538669
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/mathExpressions.scala:
##########
@@ -275,6 +292,21 @@ case class Ceil(child: Expression) extends
UnaryMathExpression(math.ceil, "CEIL"
case DecimalType.Fixed(_, _) =>
defineCodeGen(ctx, ev, c => s"$c.ceil()")
case LongType => defineCodeGen(ctx, ev, c => s"$c")
+ case DoubleType if failOnError =>
+ nullSafeCodeGen(ctx, ev, c => {
+ val roundedValue = ctx.freshName("roundedValue")
+ val errorContext = getContextOrNullCode(ctx)
+ s"""
+ |double $roundedValue = java.lang.Math.${funcName}($c);
Review Comment:
Nit (non-blocking): this codegen overflow template is duplicated verbatim in
`Floor.doGenCode` below (only `funcName` differs). The interpreted side was
already factored into `CeilFloor.doubleToLong`; consider a matching `CeilFloor`
codegen helper so the two stay in sync. Purely a maintainability suggestion.
--
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]