fn make_downscaler<I: DecimalType, O: DecimalType>(
input_precision: u8,
input_scale: i8,
output_precision: u8,
output_scale: i8,
) -> Option<(impl Fn(I::Native) -> Option<O::Native>, Option<impl Fn(I::Native) -> O::Native>)>where
I::Native: DecimalCast + ArrowNativeTypeOp,
O::Native: DecimalCast + ArrowNativeTypeOp,Expand description
Construct closures to downscale decimals from (input_precision, input_scale) to
(output_precision, output_scale).
Returns (f_fallible, f_infallible) where:
f_fallibleyieldsNonewhen the requested cast would overflowf_infallibleis present only when every input is guaranteed to succeed; otherwise it isNoneand callers must fall back tof_fallible
Returns None if the required scale reduction delta_scale = input_scale - output_scale
exceeds the supported precomputed precision table I::MAX_FOR_EACH_PRECISION.
In this scenario, any value would round to zero (e.g., dividing by 10^k where k exceeds the
available precision). Callers should therefore produce zero values (preserving nulls) rather
than returning an error.