make_upscaler

Function make_upscaler 

Source
fn make_upscaler<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 upscale decimals from (input_precision, input_scale) to (output_precision, output_scale).

Returns (f_fallible, f_infallible) where:

  • f_fallible yields None when the requested cast would overflow
  • f_infallible is present only when every input is guaranteed to succeed; otherwise it is None and callers must fall back to f_fallible

Returns None if the required scale increase delta_scale = output_scale - input_scale exceeds the supported precomputed precision table O::MAX_FOR_EACH_PRECISION. In that case, the caller should treat this as an overflow for the output scale and handle it accordingly (e.g., return a cast error).