Skip to content

Commit d096558

Browse files
authored
Refactor scalar min/max dispatch into function-based helpers (#22062)
## Which issue does this PR close? * Closes #22061. ## Rationale for this change The existing `min_max_scalar_impl!` macro combined dispatch, validation, recursion, and control flow into a large macro expansion, making the logic difficult to debug, review, and test in isolation. This change moves scalar min/max dispatch to a function-based implementation while preserving existing behavior, error messages, and dictionary handling semantics. ## What changes are included in this PR? * Replaced the `min_max_scalar_impl!` macro with function-based dispatch logic. * Added helper functions to separate responsibilities: * `min_max_option` * `min_max_float_option` * `ensure_decimal_compatibility` * `min_max_generic_scalar` * `min_max_interval_scalar` * `min_max_dictionary_scalar` * `min_max_scalar_same_variant` * Kept `min_max_scalar` as the main entry point and delegated behavior through helper functions. * Preserved: * existing min/max behavior across scalar types * dictionary comparison and rewrapping semantics * decimal precision/scale validation behavior * float `NaN` handling via `total_cmp` * existing error classifications and messages * compacting behavior for generic scalar comparisons * Simplified macro usage by retaining only lightweight ordering-selection macros. ## Are these changes tested? Yes. Added unit tests covering: * core scalar min/max parity behavior * float `NaN` handling using `total_cmp` * decimal mismatch error preservation * fixed-size binary mismatch error preservation * mixed interval comparison error preservation Existing dictionary comparison tests are also preserved. ## Are there any user-facing changes? No. This PR is intended to be a refactor only and preserves existing externally visible behavior. ## LLM-generated code disclosure This PR includes LLM-generated code and comments. All LLM-generated content has been manually reviewed and tested.
1 parent bd904b3 commit d096558

1 file changed

Lines changed: 432 additions & 406 deletions

File tree

  • datafusion/functions-aggregate-common/src

0 commit comments

Comments
 (0)