coderfender commented on code in PR #20593:
URL: https://github.com/apache/datafusion/pull/20593#discussion_r2969854906


##########
datafusion/spark/src/function/math/ceil.rs:
##########
@@ -108,7 +108,7 @@ fn spark_ceil_scalar(value: &ScalarValue) -> 
Result<ColumnarValue> {
         ScalarValue::Float64(v) => ScalarValue::Int64(v.map(|x| x.ceil() as 
i64)),
         v if v.data_type().is_integer() => v.clone(),
         ScalarValue::Decimal128(v, p, s) if *s > 0 => {
-            let div = 10_i128.pow(*s as u32);
+            let div = 10_i128.pow_wrapping(*s as u32);
             let new_p = ((*p as i64) - (*s as i64) + 1).clamp(1, 38) as u8;

Review Comment:
   There is a lot of duplication in the code between scalar and array inputs. 
Can we create simple functions and inline them to not repeat ourselves ?



-- 
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]

Reply via email to