Jefffrey commented on code in PR #19752:
URL: https://github.com/apache/datafusion/pull/19752#discussion_r2680507437
##########
datafusion/functions/src/math/ceil.rs:
##########
@@ -95,6 +95,31 @@ impl ScalarUDFImpl for CeilFunc {
}
fn invoke_with_args(&self, args: ScalarFunctionArgs) ->
Result<ColumnarValue> {
+ let arg = &args.args[0];
+
+ // Scalar fast path for float types - avoid array conversion overhead
+ // Note: Decimal types use the array path for proper
precision/overflow validation
+ if let ColumnarValue::Scalar(scalar) = arg {
+ match scalar {
+ ScalarValue::Float64(v) => {
+ return Ok(ColumnarValue::Scalar(ScalarValue::Float64(
+ v.map(f64::ceil),
+ )));
+ }
+ ScalarValue::Float32(v) => {
+ return Ok(ColumnarValue::Scalar(ScalarValue::Float32(
+ v.map(f32::ceil),
+ )));
+ }
+ ScalarValue::Null => {
+ return
Ok(ColumnarValue::Scalar(ScalarValue::Float64(None)));
+ }
+ // Decimal types fall through to array path for overflow
validation
Review Comment:
For decimals, we could turn the scalars in arrays of size 1, pass through
the existing code, then recreate a scalar from the resultant array, to benefit
from code reuse and ensure we don't expand the array.
Not the cleanest way to do it but certainly the easiest.
--
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]