Skip to content

[core] Validate data types for max/min aggregate functions - #9013

Open
jackylee-ch wants to merge 1 commit into
apache:masterfrom
jackylee-ch:core-minmax-agg-validation
Open

[core] Validate data types for max/min aggregate functions#9013
jackylee-ch wants to merge 1 commit into
apache:masterfrom
jackylee-ch:core-minmax-agg-validation

Conversation

@jackylee-ch

@jackylee-ch jackylee-ch commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Purpose

FieldMaxAggFactory / FieldMinAggFactory create the aggregator without checking the column type. FieldMaxAgg#agg delegates to InternalRowUtils.compare, which only handles ordered types, so fields.<f>.aggregate-function = max on an ARRAY / MAP / ROW / VARIANT / BLOB / VECTOR column is accepted and only fails later during merging with Incomparable type: ARRAY, naming neither the field nor the function. #4446 moved this kind of check into the factories and #7485 did the same for listagg; max/min were never migrated.

compare also had no BOOLEAN case, although TypeCheckUtils.isComparable treats BOOLEAN as comparable and the codegen comparator already implements it, so BOOLEAN is added rather than rejected. The doc lists for max/min were missing BOOLEAN, BINARY and VARBINARY.

Tests

FieldAggregatorTest, InternalRowUtilsTest.

@jackylee-ch
jackylee-ch force-pushed the core-minmax-agg-validation branch 3 times, most recently from 1fb5c22 to 3875e90 Compare August 5, 2026 10:04
### Purpose

`FieldMaxAggFactory` / `FieldMinAggFactory` create the aggregator without checking the column type. `FieldMaxAgg#agg` delegates to `InternalRowUtils.compare`, which only handles ordered types, so `fields.<f>.aggregate-function = max` on an ARRAY / MAP / MULTISET / ROW / VARIANT / BLOB / VECTOR column is accepted and only fails later during merging with `Incomparable type: ARRAY`, naming neither the field nor the function. apache#4446 moved this kind of check into the factories and apache#7485 did the same for `listagg`; max/min were never migrated.

`compare` also had no BOOLEAN case, although `TypeCheckUtils.isComparable` treats BOOLEAN as comparable and the codegen comparator already implements it, so BOOLEAN is added rather than rejected. With that, the set of types the factory admits equals the set `compare` can order; a test pins the invariant.

### Tests

`FieldAggregatorTest`, `InternalRowUtilsTest`.
@jackylee-ch
jackylee-ch force-pushed the core-minmax-agg-validation branch from 3875e90 to 760a5f7 Compare August 5, 2026 11:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant