sathiyapk commented on a change in pull request #34729:
URL: https://github.com/apache/spark/pull/34729#discussion_r770529639
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/mathExpressions.scala
##########
@@ -249,9 +249,9 @@ case class Cbrt(child: Expression) extends
UnaryMathExpression(math.cbrt, "CBRT"
""",
since = "1.4.0",
group = "math_funcs")
-case class Ceil(child: Expression) extends UnaryMathExpression(math.ceil,
"CEIL") {
+ case class Ceil(child: Expression) extends UnaryMathExpression(math.ceil,
"CEIL") {
override def dataType: DataType = child.dataType match {
Review comment:
@cloud-fan You are right, we need `ExpressionBuilder` for the sql part.
I've added the expression builder for `ceil` and `floor` and enough test cases
in `MathFunctionsSuite` and it looks fine. I'll push the modifications along
with other review comments.
```
object CeilExpressionBuilder extends ExpressionBuilder {
def build(expressions: Seq[Expression]): Expression = {
if (expressions.length == 1) Ceil(expressions.head)
else if (expressions.length == 2) Ceil(expressions(0), expressions(1))
else throw new AnalysisException("Function ceil cannot take more than 2
parameters")
}
}
object FloorExpressionBuilder extends ExpressionBuilder {
def build(expressions: Seq[Expression]): Expression = {
if (expressions.length == 1) Floor(expressions.head)
else if (expressions.length == 2) Floor(expressions(0), expressions(1))
else throw new AnalysisException("Function floor cannot take more than 2
parameters")
}
}
```
And I believe, for now it will be safer to conserve the same behaviour for
`ceil`/`floor` without `scale` parameter or when `scale = 0` and follow the
behaviour of `round` when scale parameter is specified and `>0`. I think you
prefer the same ?
--
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]