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

Function pow_decimal_float_fallback

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

Fallback implementation using f64 for negative or non-integer exponents. This handles cases that cannot be computed using integer arithmetic.

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

Source from the content-addressed store, hash-verified

252/// Fallback implementation using f64 for negative or non-integer exponents.
253/// This handles cases that cannot be computed using integer arithmetic.
254fn pow_decimal_float_fallback<T>(base: T, scale: i8, exp: f64) -> Result<T, ArrowError>
255where
256 T: ToPrimitive + NumCast + Copy,
257{
258 if scale < 0 {
259 return Err(ArrowError::NotYetImplemented(format!(
260 "Negative scale is not yet supported: {scale}"
261 )));
262 }
263
264 let scale_factor = 10f64.powi(scale as i32);
265 let base_f64 = base.to_f64().ok_or_else(|| {
266 ArrowError::ComputeError("Cannot convert base to f64".to_string())
267 })? / scale_factor;
268
269 let result_i128 = compute_pow_f64_result(base_f64, scale, exp)?;
270
271 decimal_from_i128(result_i128)
272}
273
274/// Decimal256 specialized float exponent version.
275fn pow_decimal256_float(base: i256, scale: i8, exp: f64) -> Result<i256, ArrowError> {

Callers 1

pow_decimal_floatFunction · 0.85

Calls 3

compute_pow_f64_resultFunction · 0.85
decimal_from_i128Function · 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…