kumarUjjawal commented on code in PR #19831:
URL: https://github.com/apache/datafusion/pull/19831#discussion_r2696993971
##########
datafusion/functions/src/math/round.rs:
##########
@@ -141,6 +141,50 @@ impl ScalarUDFImpl for RoundFunc {
&default_decimal_places
};
+ // Scalar fast path for float types - avoid array conversion overhead
+ if let (ColumnarValue::Scalar(value_scalar),
ColumnarValue::Scalar(dp_scalar)) =
+ (&args.args[0], decimal_places)
+ {
+ // Extract decimal places as i32
+ let dp = match dp_scalar {
+ ScalarValue::Int32(Some(dp)) => *dp,
+ ScalarValue::Int32(None) => {
+ return
Ok(ColumnarValue::Scalar(ScalarValue::Float64(None)));
+ }
+ _ => {
+ // Fall through to array path for non-Int32 decimal places
+ return round_columnar(
+ &args.args[0],
+ decimal_places,
+ args.number_rows,
+ );
+ }
+ };
+
+ match value_scalar {
+ ScalarValue::Float64(Some(v)) => {
+ let factor = 10_f64.powi(dp);
Review Comment:
Good call.
--
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]