Describe the bug
When implementing fix: array to array cast, the test of casting ArrayType(DecimalType(10,2)) to ArrayType(ShortType) failed with following error, where comet formats -96833550.07 to -96833550.7DB.
"...The value -96833550.[]7BD of the type "DEC..." did not equal "...The value -96833550.[0]7BD of the type "DEC..." (CometCastSuite.scala:1328)
It looks to be related to cast_decimal_to_int16_down
|
macro_rules! cast_decimal_to_int16_down { |
|
( |
|
$array:expr, |
|
$eval_mode:expr, |
|
$dest_array_type:ty, |
|
$rust_dest_type:ty, |
|
$dest_type_str:expr, |
|
$precision:expr, |
|
$scale:expr |
|
) => {{ |
|
let cast_array = $array |
|
.as_any() |
|
.downcast_ref::<Decimal128Array>() |
|
.expect("Expected a Decimal128ArrayType"); |
|
|
|
let output_array = match $eval_mode { |
|
EvalMode::Ansi => cast_array |
|
.iter() |
|
.map(|value| match value { |
|
Some(value) => { |
|
let divisor = 10_i128.pow($scale as u32); |
|
let (truncated, decimal) = (value / divisor, (value % divisor).abs()); |
|
let is_overflow = truncated.abs() > i32::MAX.into(); |
It can be proven by printing the original and truncated values.
casting value: -9683355007, truncated: -96833550, decimal: 7, is_overflow: false
Steps to reproduce
No response
Expected behavior
No response
Additional context
No response
Describe the bug
When implementing fix: array to array cast, the test of casting
ArrayType(DecimalType(10,2))toArrayType(ShortType)failed with following error, where comet formats-96833550.07to-96833550.7DB.It looks to be related to
cast_decimal_to_int16_downdatafusion-comet/native/spark-expr/src/conversion_funcs/cast.rs
Lines 674 to 696 in 5ec12d4
It can be proven by printing the original and truncated values.
Steps to reproduce
No response
Expected behavior
No response
Additional context
No response