andygrove opened a new pull request, #4937: URL: https://github.com/apache/datafusion-comet/pull/4937
## Which issue does this PR close? Part of #4936. ## Rationale for this change `CheckOverflow` wraps the result of every decimal `+ - * /`, `sum`, and `avg`, so it runs on the hot path of most TPC-DS queries. The non-ANSI path (Spark's default) always allocated a new `Decimal128` array via `null_if_overflow_precision`, even when no value overflowed, which is the common case. ## What changes are included in this PR? Adds a fast path to the array branch of `CheckOverflow::evaluate` that reuses the input buffers when no value overflows the target precision (`to_data()` clones only cheap Arc metadata, no element copy). The overflow check uses `all`, which short-circuits at the first overflow, so the fallback null-masking path pays at most a tiny extra scan and does not regress. The ANSI branch is unchanged in behavior. Also adds array-path unit tests (only scalar inputs were covered before) and a criterion benchmark. ## How are these changes tested? New Rust unit tests cover the array path in both legacy and ANSI modes: no-overflow reuse (values, nulls, and target precision/scale preserved), overflow nulling in legacy mode, and overflow raising in ANSI mode. Existing scalar tests are unchanged. Benchmark (criterion), baseline `main` vs this branch, 8192-row Decimal128 columns, two independent samples: ``` check_overflow: no overflow: 5.63 µs -> 5.11 µs (-9 to -10%) check_overflow: no overflow, with nulls: 7.46 µs -> 6.14 µs (-17 to -18%) check_overflow: ansi no overflow: 16.61 µs -> 16.35 µs (-2.4%) check_overflow: sparse overflow: 5.71 µs -> 5.71 µs (within noise) check_overflow: dense overflow: 8.76 µs -> 8.80 µs (within noise) ``` The no-overflow shapes (the common case) hit the fast path; the overflow shapes run the unchanged null-masking path and are within noise across both samples. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
