Skip to content

Commit 6b3e7cc

Browse files
committed
Comment cleanup
1 parent 3de8efd commit 6b3e7cc

3 files changed

Lines changed: 7 additions & 16 deletions

File tree

datafusion/functions/src/math/power.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -370,8 +370,6 @@ fn pow_decimal256_float_fallback(
370370

371371
/// Compute `power(decimal_base, float_exponent)` by casting the base to
372372
/// `Float64` and running `pow` in float space; returns `Float64`.
373-
/// `calculate_binary_math` casts the exponent internally and preserves
374-
/// scalar shape, so we only need to materialize the base here.
375373
fn pow_decimal_via_float64(
376374
base: &ColumnarValue,
377375
exponent: &ColumnarValue,
@@ -399,11 +397,9 @@ impl ScalarUDFImpl for PowerFunc {
399397

400398
fn return_type(&self, arg_types: &[DataType]) -> Result<DataType> {
401399
// Return type as a function of (base, exponent). After signature
402-
// coercion the operands are one of three shapes, plus a NULL on
403-
// either side when an operand is a literal NULL:
400+
// coercion, we have to handle the following cases:
404401
//
405-
// - NULL on either side -> Float64 (matches the other math
406-
// UDFs, which all return Float64 for NULL input)
402+
// - NULL on either side -> Float64 (typed NULL)
407403
// - (Decimal, Float64) -> Float64
408404
// - (Decimal, Int64) -> the base's Decimal type
409405
// - (Float64, Float64) -> Float64
@@ -424,8 +420,8 @@ impl ScalarUDFImpl for PowerFunc {
424420
fn invoke_with_args(&self, args: ScalarFunctionArgs) -> Result<ColumnarValue> {
425421
let [base, exponent] = take_function_args(self.name(), &args.args)?;
426422

427-
// No native kernel exists for `(Decimal, Float64)`; bridge via
428-
// Float64. The match below handles the remaining coerced shapes.
423+
// No native kernel exists for `(Decimal, Float64)`; bridge by casting
424+
// the base to Float64.
429425
if base.data_type().is_decimal() && exponent.data_type().is_floating() {
430426
return pow_decimal_via_float64(base, exponent, args.number_rows);
431427
}

datafusion/sqllogictest/test_files/decimal.slt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,11 +1118,6 @@ SELECT power(2.5::decimal(38, 3), 4), arrow_typeof(power(2.5::decimal(38, 3), 4)
11181118
----
11191119
39.062 Decimal128(38, 3)
11201120

1121-
# `power(decimal, float)` returns Float64: the result can grow beyond the
1122-
# base's Decimal precision (e.g. `2.5 ^ 4.0 = 39.0625` does not fit in
1123-
# `Decimal128(2, 1)`), so the function widens to Float64 instead of
1124-
# silently truncating. Inf / NaN are representable in Float64, so the
1125-
# edge cases below succeed rather than erroring on Decimal cast.
11261121
query RT
11271122
SELECT power(2.5, 4.0), arrow_typeof(power(2.5, 4.0));
11281123
----

datafusion/sqllogictest/test_files/math.slt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -818,9 +818,9 @@ from values
818818
81
819819
NULL
820820

821-
# `power` accepts (Decimal, Int), (Decimal, Float), or (Float, Float) -- there
822-
# is no form that takes a Decimal exponent. So a Decimal exponent coerces to
823-
# Float64, and `power(decimal, float)` returns Float64.
821+
# There is no variant of `power` that accepts (Decimal, Decimal); type coercion
822+
# will cast the exponent to `Float64`, and `power(decimal, float)` returns
823+
# `Float64`.
824824
query RT rowsort
825825
select
826826
power(base::decimal(38, 0), exponent::decimal(38, 0)),

0 commit comments

Comments
 (0)