cloud-fan commented on a change in pull request #34729:
URL: https://github.com/apache/spark/pull/34729#discussion_r783085125
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/mathExpressions.scala
##########
@@ -484,9 +516,62 @@ case class Floor(child: Expression) extends
UnaryMathExpression(math.floor, "FLO
case LongType => defineCodeGen(ctx, ev, c => s"$c")
case _ => defineCodeGen(ctx, ev, c =>
s"(long)(java.lang.Math.${funcName}($c))")
}
+ }
+ override protected def withNewChildInternal(newChild: Expression): Floor =
+ copy(child = newChild)
+}
+
+@ExpressionDescription(
+ usage = """
+ _FUNC_(expr[, scale]) - Returns the largest number after rounding down that
is not greater
+ than `expr`. An optional `scale` parameter can be specified to control the
rounding behavior.""",
+ examples = """
+ Examples:
+ > SELECT _FUNC_(-0.1);
+ -1
+ > SELECT _FUNC_(5);
+ 5
+ > SELECT _FUNC_(3.1411, 3);
+ 3.141
+ > SELECT _FUNC_(3.1411, -3);
+ 0
+ """,
+ since = "3.3.0",
+ group = "math_funcs")
+object FloorExpressionBuilder extends ExpressionBuilder {
Review comment:
This is very similar to `CeilExpressionBuilder`. Can we have a `trait
CeilFloorExprBuilderBase` to put the common code?
--
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]