Jefffrey commented on PR #21710:
URL: https://github.com/apache/datafusion/pull/21710#issuecomment-4598148838
I was checking some outputs against Spark 4.1.2, and it seems they actually
operate only on decimal types for the 2-arg variant. See:
```python
>>> spark.sql("select ceil(-25::int)").printSchema()
root
|-- CEIL(CAST(-25 AS INT)): long (nullable = true)
>>> spark.sql("select ceil(-25::int, -1)").printSchema()
root
|-- ceil(CAST(-25 AS INT), -1): decimal(11,0) (nullable = true)
```
And see reference code:
```scala
case class RoundCeil(child: Expression, scale: Expression)
extends RoundBase(child, scale, BigDecimal.RoundingMode.CEILING,
"ROUND_CEILING") {
override def inputTypes: Seq[AbstractDataType] = Seq(DecimalType,
IntegerType)
override def nodeName: String = "ceil"
override protected def withNewChildrenInternal(
newLeft: Expression, newRight: Expression): RoundCeil =
copy(child = newLeft, scale = newRight)
}
```
-
https://github.com/apache/spark/blob/d6036f470d750a8296016f4a8a88c17679295505/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/mathExpressions.scala#L332-L342
- Input types seem to force it to decimal
So I think this PR won't align with Spark since we need to operate only on
decimals (and subsequently return decimal types)?
--
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]