navina opened a new pull request, #18842:
URL: https://github.com/apache/pinot/pull/18842

   ## Summary
   
   `mergeDataTablesOnly` reused `getIndexedTable`, which unconditionally called 
`indexedTable.finish(true, true)`. For a `GROUP BY` query with an OBJECT-typed 
intermediate aggregate (`DISTINCTCOUNT`, `DISTINCTCOUNTHLL`, etc.), that 
`storeFinalResult=true` call:
   
   - mutated `DataSchema._columnDataTypes` from `OBJECT` to the final-result 
type **in place** (`IndexedTable.java:170-174`), and
   - replaced each row's value with `extractFinalResult(value)` (`Set → 
Integer` for `DISTINCTCOUNT`) at `IndexedTable.java:195`.
   
   The subsequent `buildIntermediateDataTable` read `DataSchema`'s cached 
`_storedColumnDataTypes` — populated earlier from the pre-finalize OBJECT 
schema and never invalidated by `finish` — so the OBJECT branch fired and 
handed the now-`Integer` value into 
`BaseDistinctAggregateAggregationFunction.serializeIntermediateResult(Set)`, 
which threw `ClassCastException`.
   
   ## Fix
   
   Move `finish()` out of `getIndexedTable` and let each caller pick the right 
mode:
   
   - `reduceResult` keeps `finish(true, true)` — downstream consumers expect 
final scalars.
   - `mergeDataTablesOnly` calls `finish(true, false)` so aggregate values stay 
as intermediates and round-trip through `buildIntermediateDataTable` correctly.
   
   ## Tests
   
   Adds `testGroupByDistinctCountObjectRoundTrip` regression in 
`MergeDataTablesOnlyTest`: server emits intermediate OBJECT-encoded `Set`s, 
merge produces a re-injectable intermediate `DataTable`, and reducing that 
intermediate matches a direct reduce of the same servers.
   
   ## Release Notes
   
   Fixes a `ClassCastException` in `mergeDataTablesOnly` when merging `GROUP 
BY` results that include OBJECT-typed intermediate aggregates (e.g. 
`DISTINCTCOUNT`, `DISTINCTCOUNTHLL`). Affects callers of 
`BrokerReduceService.mergeOnDataTable` for these query shapes.
   


-- 
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]

Reply via email to