liukun4515 commented on code in PR #2357:
URL: https://github.com/apache/arrow-rs/pull/2357#discussion_r940290081
##########
arrow/src/compute/kernels/cast.rs:
##########
@@ -1276,8 +1277,17 @@ fn cast_decimal_to_decimal(
.iter()
.map(|v| v.map(|v| v.as_i128() * mul))
.collect::<Decimal128Array>()
- }
- .with_precision_and_scale(*output_precision, *output_scale)?;
+ };
+ // For decimal cast to decimal, if the range of output is gt_eq than the
input, don't need to
+ // do validation.
+ let output_array = match output_precision-output_scale>=input_precision -
input_scale {
+ true => {
+ output_array.with_precision_and_scale(*output_precision,
*output_scale, false)
Review Comment:
@HaoYang670
create array from reading data from parquet
https://github.com/apache/arrow-rs/blob/9a630a10980aec65b045e59ca7c412c79eb07f65/parquet/src/arrow/array_reader/primitive_array.rs#L187
create a new decimal array from casting
https://github.com/apache/arrow-rs/blob/9a630a10980aec65b045e59ca7c412c79eb07f65/arrow/src/compute/kernels/cast.rs#L1255
In cast case, if the target decimal type has larger range, we can ignore the
validation.
For example, cast decimal(10,3) to decimal(12,3) don't need to do the
validation, even int32 to decimal(12,0) also don't need to do validation.
--
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]