Repository navigation
Conversation
zhangfengcdt
left a comment
There was a problem hiding this comment.
Thanks for the refactoring and it is nice and clean! I found no issues.
comphead
left a comment
There was a problem hiding this comment.
Behavior is identical on all four call sites. In DataFusion 55.2.0, ColumnarValue::values_to_arrays expands scalars to the array length and uses a length of 1 when every input is a scalar, which is what the removed matches did with to_array(). The scalar-in, scalar-out handling is untouched because checked_float_modulo and WideDecimalBinaryExpr::evaluate decide it from the original inputs before or after the call. checked_arithmetic_internal and spark_decimal_div_internal already returned arrays for two scalars. The only change is that two arrays of different lengths now fail up front with an internal error. This PR conflicts textually with #7811 in wide_decimal_binary_expr.rs (git merge-tree reports a content conflict near the left_arr and _p1 lines), which is easy to resolve by whichever PR lands second. I did not run any tests.
9f29ee4 to
de6d883
Compare
Which issue does this PR close?
Closes #6982.
Rationale for this change
As stated in the issue, these four call sites all duplicate code to turn a pair of
ColumnarValues intoArrayRefs. We want to minimize duplicate code for potential future changes to how scalar broadcasting works.What changes are included in this PR?
checked_arithmetic_internal,spark_decimal_div_internal,checked_float_moduloandWideDecimalBinaryExpr::evaluatenow callColumnarValue::values_to_arraysinstead of their own match.
ArrayRefimports are removed.values_to_arraysrather than adding abroadcast_pairhelper, because it alreadyexpands two scalars into length-1 arrays (
array_len.unwrap_or(1)), which is what the oldmatch did.
ansi_arithmetic_kernelis left as is: it wraps scalars in arrow'sScalarso thekernel can use its scalar fast path, and
values_to_arrayswould materialize them into full arrays.values_to_arraysstraight away, instead of failing later.How are these changes tested?
No new tests are added, as existing tests cover the behaviour. Tests run with the following commands are green:
cargo test -p datafusion-comet-spark-exprcargo clippy -p datafusion-comet-spark-expr --all-targets -- -D warningscargo fmt --all -- --check