Github user chenghao-intel commented on a diff in the pull request:
https://github.com/apache/spark/pull/9086#discussion_r42071708
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/mathExpressions.scala
---
@@ -153,13 +153,29 @@ case class Atan(child: Expression) extends
UnaryMathExpression(math.atan, "ATAN"
case class Cbrt(child: Expression) extends UnaryMathExpression(math.cbrt,
"CBRT")
case class Ceil(child: Expression) extends UnaryMathExpression(math.ceil,
"CEIL") {
- override def dataType: DataType = LongType
- protected override def nullSafeEval(input: Any): Any = {
- f(input.asInstanceOf[Double]).toLong
+ override def dataType: DataType = child.dataType match {
+ case dt @ DecimalType.Fixed(_, 0) => dt
+ case DecimalType.Fixed(precision, scale) =>
+ DecimalType.bounded(precision - scale + 1, 0)
+ case _ => LongType
+ }
+
+ override def inputTypes: Seq[AbstractDataType] =
+ Seq(TypeCollection(DoubleType, FloatType, DecimalType))
--- End diff --
This was actually for performance concern, we don't want to make extra
casting from `Float` -> `Double`; After double checking the function
`math.ceil`, seems it only support the `double` type. I will update the code.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]