MCPcopy Create free account
hub / github.com/apache/datafusion / pow_decimal256_float_fallback

Function pow_decimal256_float_fallback

datafusion/functions/src/math/power.rs:350–370  ·  view source on GitHub ↗

Fallback implementation for Decimal256.

(
    base: i256,
    scale: i8,
    exp: f64,
)

Source from the content-addressed store, hash-verified

348
349/// Fallback implementation for Decimal256.
350fn pow_decimal256_float_fallback(
351 base: i256,
352 scale: i8,
353 exp: f64,
354) -> Result<i256, ArrowError> {
355 if scale < 0 {
356 return Err(ArrowError::NotYetImplemented(format!(
357 "Negative scale is not yet supported: {scale}"
358 )));
359 }
360
361 let scale_factor = 10f64.powi(scale as i32);
362 let base_f64 = base.to_f64().ok_or_else(|| {
363 ArrowError::ComputeError("Cannot convert base to f64".to_string())
364 })? / scale_factor;
365
366 let result_i128 = compute_pow_f64_result(base_f64, scale, exp)?;
367
368 // i256 can be constructed from i128 directly
369 Ok(i256::from_i128(result_i128))
370}
371
372/// Fallback implementation for decimal power when exponent is an array.
373/// Casts decimal to float64, computes power, and casts back to original decimal type.

Callers 1

pow_decimal256_floatFunction · 0.85

Calls 2

compute_pow_f64_resultFunction · 0.85
to_stringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…