Repository navigation
Conversation
2528750 to
1951444
Compare
1951444 to
9528cd9
Compare
JingsongLi
left a comment
There was a problem hiding this comment.
Rejecting an incompatible aggregator at DDL time is valuable. The local JDK 8 reactor passed all 229 selected schema, aggregate and partial-update tests. A separate time-travel test passed on the exact base and failed on this head. The upstream Core failure is the separate CSV regression tracked in #10998.
| } | ||
| // Instantiate once so that type-incompatible configurations (e.g. 'collect' on a | ||
| // non-array column) are rejected at DDL time instead of at read/write time. | ||
| FieldAggregatorFactory.create( |
There was a problem hiding this comment.
[P1] Keep valid historical projections readable after aggregate schema evolution
AbstractFileStoreTable.runtimeStore() also runs this check, before the read projection is applied. I created a primary-key partial-update table with label VARCHAR(16) protected by fields.seq.sequence-group=label, wrote snapshot 1, and widened label to STRING while enabling listagg through ALTER. Both DDL operations succeed. A read of only id at snapshot 1 passes on the base and now fails before planning with list agg column must be STRING ... VARCHAR(16), because time travel combines the old type with current options. The same eager check also blocks previously working projections on pre-upgrade tables with incompatible aggregators on unused columns. Please run the eager type check on CREATE/ALTER and preserve the runtime projection behavior for stored schemas. Add the historical projection as a regression test.
There was a problem hiding this comment.
Agreed — I'll restrict the eager check to the CREATE/ALTER schema-commit path so reads of stored schemas keep the previous projection-scoped behavior, and add a regression test for the time-travel projection you described.
Problem
CREATE TABLEaccepts anaggregate-functionthat is incompatible with the column type, and the failure only surfaces later on the data path:Any read, write, or compaction on that table then fails deterministically with:
The cause is that
SchemaValidation#validateMergeFunctionFactoryonly callsFactoryUtil.discoverFactory, i.e. it verifies that the aggregation function name exists, but never callsFieldAggregatorFactory#create, which is where the type checks live. So DDL only proves the merge engine is valid and the function name is spelled correctly.The same gap applies to the other type-checking aggregators (
sum,product,listagg,merge_map,hll_sketch,theta_sketch,roaringbitmap32/64,bool_and/bool_or,nested_update,nested_partial_update). It is also present forpartial-update:PartialUpdateMergeFunctionwraps each aggregator in aSupplier, so even instantiating the merge function does not trigger the check.Because the resulting
IllegalArgumentExceptionis deterministic and maps to HTTP 400 in REST catalogs, an invalid table is effectively unreadable until someone fixes its options or drops it.Fix
Instantiate each aggregation factory once during schema validation, so type-incompatible configurations are rejected at
CREATE TABLE/ALTER TABLEtime, reusing the existing factory error messages:aggregation: resolve the function throughAggregateMergeFunction#getAggFuncName(primary key columns map toprimary_key, sequence fields tolast_value, otherwise field-level option then default), then instantiate.partial-update/versioned-partial-update: skip sequence fields, map primary key columns toprimary_key, otherwise use the field-level option or the default. Fields that never get an aggregator are skipped: sequence-group ordering fields forpartial-update, and multi-version columns forversioned-partial-update.No behavior change for valid tables; the check only constructs the object that the read/write path would have constructed anyway.
Tests
collect/sumon aSTRINGcolumn now fails at DDL time for bothaggregationandpartial-update.collectonARRAY<STRING>,sumon a numeric column) still pass.partial-updatesequence-group ordering field configured with an incompatible aggregation function is not rejected, since it never gets an aggregator.SchemaManagerTest#testResetSequenceGroupForAggregateFunctionused aVARCHARcolumn withsum; the column type is corrected so the fixture is valid.