cloud-fan commented on a change in pull request #34729:
URL: https://github.com/apache/spark/pull/34729#discussion_r779581471



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/mathExpressions.scala
##########
@@ -279,6 +269,59 @@ case class Ceil(child: Expression) extends 
UnaryMathExpression(math.ceil, "CEIL"
   override protected def withNewChildInternal(newChild: Expression): Ceil = 
copy(child = newChild)
 }
 
+@ExpressionDescription(
+  usage = "_FUNC_(expr[, scale]) - Returns the smallest number after rounding 
up that" +
+    " is not smaller than `expr`. A optional `scale` parameter can be 
specified to" +
+    " control the rounding behavior.",
+  examples = """
+    Examples:
+      > SELECT _FUNC_(-0.1);
+       0
+      > SELECT _FUNC_(5);
+       5
+      > SELECT _FUNC_(3.1411, 3);
+       3.142
+      > SELECT _FUNC_(3.1411, -3);
+       1000
+  """,
+  since = "3.3.0",
+  group = "math_funcs")
+object CeilExpressionBuilder extends ExpressionBuilder {
+  def build(expressions: Seq[Expression]): Expression = {
+    if (expressions.length == 1) {
+      Ceil(expressions.head)
+    } else if (expressions.length == 2) {
+      val child = expressions(0)
+      val scale = expressions(1)
+      if (! (scale.foldable && scale.dataType == DataTypes.IntegerType)) {
+        throw new AnalysisException("Invalid scale parameter for the function 
ceil")

Review comment:
       let's define the error in `QueryCompilationError.scala`




-- 
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]

Reply via email to