Indian-boult commented on code in PR #20331:
URL: https://github.com/apache/pinot/pull/20331#discussion_r4672726598
##########
pinot-core/src/main/java/org/apache/pinot/core/operator/filter/RangeIndexBasedFilterOperator.java:
##########
@@ -101,10 +101,12 @@ private BlockDocIdSet evaluateLegacyRangeFilter() {
if (partialMatches == null) {
return matches != null ? BitmapDocIdSet.create(matches, _numDocs) :
EmptyDocIdSet.unscanned();
}
- // Need to scan the first and last range as they might be partially matched
+ // Need to scan the first and last range as they might be partially
matched. Scan without null handling because the
+ // caller takes the null rows out of the combined result, and doing it in
the scan as well wraps the scan result
+ // into a doc id set whose iterator is not a ScanBasedDocIdIterator.
ScanBasedFilterOperator scanBasedFilterOperator =
new ScanBasedFilterOperator(_queryContext, _predicateEvaluator,
_dataSource, _numDocs);
- BlockDocIdSet scanBasedDocIdSet = scanBasedFilterOperator.getTrues();
+ BlockDocIdSet scanBasedDocIdSet =
scanBasedFilterOperator.getNextBlockWithoutNullHandling();
Review 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.
##########
pinot-core/src/test/java/org/apache/pinot/queries/NullHandlingEnabledQueriesTest.java:
##########
@@ -382,6 +382,31 @@ public void
testFastFilteredCountExcludesNullsOnMultiValueColumn()
assertEquals(getRows(String.format("SELECT COUNT(*) FROM testTable WHERE
NOT (%s = 2)", COLUMN1)).get(0)[0], 0L);
}
+ /// A multi-value column always gets the legacy range index, which is not
exact: the documents of a range that the
+ /// predicate covers only in part are found by a scan. The null row is left
out once, from the combined result.
+ @Test
+ public void testRangeFilterOnMultiValueColumnWithLegacyRangeIndex()
+ throws Exception {
+ initializeRows();
+ for (int i = 0; i < 30; i++) {
+ insertRow(new Object[]{i, i + 1});
+ }
+ insertRow(null);
+ Schema schema = schemaBuilder().addMultiValueDimension(COLUMN1,
DataType.INT).build();
+ setUpSegments(TABLE_CONFIG_WITH_RANGE_INDEX_COLUMN, schema);
Review Comment:
Good catch, only the multi-value case was covered. I added
`testRangeFilterOnSingleValueColumnWithLegacyRangeIndex` in ea68cbdd1b. It sets
`rangeIndexVersion` to 1 on a single-value INT column and runs the same `>`,
`NOT >` and `BETWEEN` queries. Like the multi-value test, it fails on master
with the ClassCastException and passes with the fix.
--
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]