rich7420 commented on code in PR #7806:
URL: https://github.com/apache/datafusion-comet/pull/7806#discussion_r4758573806


##########
native/spark-expr/src/conversion_funcs/numeric.rs:
##########
@@ -605,18 +604,32 @@ macro_rules! cast_decimal_to_int32_up {
         let output_array: $dest_array_type = match $eval_mode {
             EvalMode::Ansi => cast_array.try_unary(|value| {
                 let truncated = value / divisor;
-                let is_overflow = truncated.abs() > $max_dest_val.into();
-                if is_overflow {
-                    return Err(cast_overflow(
+                // Keep ordinary INT values off the rounding path. INT_MIN 
needs the check below.
+                if <$rust_dest_type>::BITS == 32
+                    && truncated >= -i128::from(<$rust_dest_type>::MAX)
+                    && truncated <= i128::from(<$rust_dest_type>::MAX)
+                {
+                    return Ok(truncated as $rust_dest_type);
+                }

Review Comment:
   Spark rounds in-range expanded decimals through `DOUBLE` too. 
`DECIMAL(20,10)` `1000000000.9999999999` gave me `1000000001` in Spark, 
`1000000000` in Comet. Tracked anywhere?



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