Repository navigation
Fix ClassCastException in range filters on version 1 range indexes under null handling - #20331
Conversation
…der null handling The partial range scan in RangeIndexBasedFilterOperator took its doc ids from ScanBasedFilterOperator.getTrues() and cast the iterator to ScanBasedDocIdIterator. With null handling enabled and nulls in the column, getTrues() returns an AndDocIdSet with a bitmap iterator and the cast threw. The scan now uses getNextBlockWithoutNullHandling(), since the outer operator already handles the null rows. Fixes apache#20330
| ScanBasedFilterOperator scanBasedFilterOperator = | ||
| new ScanBasedFilterOperator(_queryContext, _predicateEvaluator, _dataSource, _numDocs); | ||
| BlockDocIdSet scanBasedDocIdSet = scanBasedFilterOperator.getTrues(); | ||
| BlockDocIdSet scanBasedDocIdSet = scanBasedFilterOperator.getNextBlockWithoutNullHandling(); |
There was a problem hiding this comment.
H3IndexFilterOperator.getFilterBlock casts ExpressionFilterOperator.getTrues().iterator() to ScanBasedDocIdIterator the same way. Can null handling wrap that result in an AndDocIdSet as well, or is it safe there?
There was a problem hiding this comment.
It's safe there. ExpressionFilterOperator extends BaseFilterOperator directly, not BaseColumnFilterOperator, so its getTrues() never goes through excludeNulls. It always returns an ExpressionDocIdSet, whose iterator is an ExpressionScanDocIdIterator, and that implements ScanBasedDocIdIterator. For an expression, null handling comes from getNulls() and getFalses() and never wraps the true set. H3IndexQueriesTest.testH3IndexWithNullHandling already runs ST_Distance(...) > 0 with null handling on, which reaches that cast through the partial match path, and it passes on this branch.
Jackie-Jiang
left a comment
There was a problem hiding this comment.
LGTM. The fix preserves null exclusion and negation semantics while keeping the partial-range scan iterator compatible with applyAnd. Both the single-value and multi-value regression tests exercise the affected legacy range-index path.
Reviewed ea68cbd. No blocking findings; two optional improvements inline. This was a static review; I did not run tests locally. All six CI workflows currently report action_required, so required checks still need to pass before merge.
Fixes #20330
The partial range scan in
RangeIndexBasedFilterOperator.evaluateLegacyRangeFilternow usesgetNextBlockWithoutNullHandling()instead ofgetTrues(). With null handling enabled and a column that holds nulls,getTrues()returns anAndDocIdSetwhose iterator is not aScanBasedDocIdIterator, and the cast right after it threw. The operator still leaves the null rows out of the final result throughBaseColumnFilterOperator.getTrues(), so the scan does not need to do it again.This affects every multi-value column with a range index, since those always use the version 1 index, and single-value columns configured with
rangeIndexVersion1.I added
NullHandlingEnabledQueriesTest.testRangeFilterOnMultiValueColumnWithLegacyRangeIndex, which runs>,NOT >andBETWEENon a nullable multi-value column with a range index. It fails on master with the ClassCastException and passes with this change. I also ran the rest ofNullHandlingEnabledQueriesTest,RangeQueriesTest,NullEnabledQueriesTest,FilterOperatorUtilsTestandExplainPlanQueriesTest, plus the pinot-core spotless, checkstyle and license checks.