parthchandra commented on code in PR #384: URL: https://github.com/apache/datafusion-comet/pull/384#discussion_r1592861816
########## core/src/execution/datafusion/expressions/cast.rs: ########## @@ -395,6 +399,58 @@ impl Cast { Ok(cast_array) } + fn cast_float64_to_decimal128( + array: &dyn Array, + precision: u8, + scale: i8, + eval_mode: EvalMode, + ) -> CometResult<ArrayRef> { + let input = array.as_any().downcast_ref::<Float64Array>().unwrap(); + let mut cast_array = PrimitiveArray::<Decimal128Type>::builder(input.len()); + + let mul = (precision as f64).powi(scale as i32); Review Comment: Makes _much_ more sense now ( I thought this might be some new Math :) ) The unit test didn't catch this because the precision in the test was 10! Perhaps we can add another unit test with some odd numbers. -- 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: github-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org