diegoQuinas commented on code in PR #21710:
URL: https://github.com/apache/datafusion/pull/21710#discussion_r3293753702
##########
datafusion/spark/src/function/math/ceil.rs:
##########
@@ -18,26 +18,33 @@
use std::sync::Arc;
use arrow::array::{ArrowNativeTypeOp, AsArray, Decimal128Array};
-use arrow::datatypes::{DataType, Decimal128Type, Float32Type, Float64Type,
Int64Type};
-use datafusion_common::utils::take_function_args;
-use datafusion_common::{Result, ScalarValue, exec_err};
+use arrow::datatypes::{
+ DataType, Decimal128Type, Float32Type, Float64Type, Int8Type, Int16Type,
Int32Type,
+ Int64Type, UInt8Type, UInt16Type, UInt32Type, UInt64Type,
+};
+use datafusion_common::types::{NativeType, logical_int32};
+use datafusion_common::{Result, ScalarValue, exec_err, not_impl_err};
use datafusion_expr::{
- ColumnarValue, ScalarFunctionArgs, ScalarUDFImpl, Signature, Volatility,
+ Coercion, ColumnarValue, ScalarFunctionArgs, ScalarUDFImpl, Signature,
TypeSignature,
+ TypeSignatureClass, Volatility,
};
+use super::scale::get_scale;
+
/// Spark-compatible `ceil` expression
/// <https://spark.apache.org/docs/latest/api/sql/index.html#ceil>
///
/// Differences with DataFusion ceil:
-/// - Spark's ceil returns Int64 for float inputs; DataFusion preserves
+/// - Spark's 1-arg `ceil` returns Int64 for float inputs; DataFusion
preserves
/// the input type (Float32→Float32, Float64→Float64)
-/// - Spark's ceil on Decimal128(p, s) returns Decimal128(p−s+1, 0), reducing
scale
+/// - Spark's `ceil` on Decimal128(p, s) returns Decimal128(p−s+1, 0),
reducing scale
/// to 0; DataFusion preserves the original precision and scale
/// - Spark only supports Decimal128; DataFusion also supports
Decimal32/64/256
/// - Spark does not check for decimal overflow; DataFusion errors on overflow
///
-/// 2-argument ceil(value, scale) is not yet implemented
-/// <https://github.com/apache/datafusion/issues/21560>
+/// Two-argument form `ceil(expr, scale)` returns the same type as `expr` for
+/// integer and floating-point inputs (regardless of `scale`). Decimal inputs
+/// are not yet supported in the 2-arg form (see TODO in execution path).
Review Comment:
Updated!
--
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]