Fix SmartHLL ClassCastException in GROUP BY ORDER BY#18841
Conversation
extractGroupByResult() blindly cast to Set but the holder can contain a HyperLogLog once the dict-ID cardinality threshold is exceeded via checkAndConvertToSketchForGroups. Mirror the threshold check already present in extractAggregationResult().
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #18841 +/- ##
============================================
+ Coverage 64.76% 64.92% +0.15%
- Complexity 1322 1347 +25
============================================
Files 3393 3395 +2
Lines 211022 212533 +1511
Branches 33135 33515 +380
============================================
+ Hits 136676 137992 +1316
- Misses 63330 63389 +59
- Partials 11016 11152 +136
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
checkAndConvertToSketchForGroups already converts DictIdsWrapper to sketch eagerly when the threshold is exceeded, so any DictIdsWrapper remaining in the holder at extract time is guaranteed to be below threshold. The cardinality guard added in the prior commit is dead code; remove it per reviewer feedback.
|
Traced the root cause and the fix looks correct. checkAndConvertToSketchForGroups (called from both aggregateGroupBySV and aggregateGroupByMV) does setValueForKey(groupKey, convertToSketch(dictIdsWrapper)) once a group's dict-id cardinality exceeds getDictIdCardinalityThreshold(), so the group holder can legitimately hold a sketch rather than a DictIdsWrapper. The old One note on the test: it plants a HyperLogLog directly via setValueForKey rather than driving aggregation past the threshold, so it pins the changed line (asserts extracted instanceof HyperLogLog and not a Set) but doesn't exercise checkAndConvertToSketchForGroups end-to-end. It's a valid regression test, but an aggregation-driven case that pushes a group over dictThreshold would guard the whole conversion->extraction path against future regressions. |
extractGroupByResult() blindly cast to Set but the holder can contain a HyperLogLog once the dict-ID cardinality threshold is exceeded via checkAndConvertToSketchForGroups. Mirror the threshold check already present in extractAggregationResult().
Labels:
bugfix