This is an automated email from the ASF dual-hosted git repository.
Jackie-Jiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pinot.git
The following commit(s) were added to refs/heads/master by this push:
new 4bd680a4da2 Fix ClassCastException in range filters on version 1 range
indexes under null handling (#20331)
4bd680a4da2 is described below
commit 4bd680a4da26a63efd2c058bb89cd768db535312
Author: Indian-boult <[email protected]>
AuthorDate: Tue Nov 24 05:51:19 2026 +0530
Fix ClassCastException in range filters on version 1 range indexes under
null handling (#20331)
---
.../filter/RangeIndexBasedFilterOperator.java | 6 +-
.../queries/NullHandlingEnabledQueriesTest.java | 67 ++++++++++++++++++++++
2 files changed, 71 insertions(+), 2 deletions(-)
diff --git
a/pinot-core/src/main/java/org/apache/pinot/core/operator/filter/RangeIndexBasedFilterOperator.java
b/pinot-core/src/main/java/org/apache/pinot/core/operator/filter/RangeIndexBasedFilterOperator.java
index 5e3d7884e57..27505f20ad5 100644
---
a/pinot-core/src/main/java/org/apache/pinot/core/operator/filter/RangeIndexBasedFilterOperator.java
+++
b/pinot-core/src/main/java/org/apache/pinot/core/operator/filter/RangeIndexBasedFilterOperator.java
@@ -101,10 +101,12 @@ public class RangeIndexBasedFilterOperator extends
BaseColumnFilterOperator {
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
+ // BaseColumnFilterOperator applies the null semantics to 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();
MutableRoaringBitmap docIds = ((ScanBasedDocIdIterator)
scanBasedDocIdSet.iterator()).applyAnd(partialMatches);
if (matches != null) {
docIds.or(matches);
diff --git
a/pinot-core/src/test/java/org/apache/pinot/queries/NullHandlingEnabledQueriesTest.java
b/pinot-core/src/test/java/org/apache/pinot/queries/NullHandlingEnabledQueriesTest.java
index c4a15643494..b2b4863a9bd 100644
---
a/pinot-core/src/test/java/org/apache/pinot/queries/NullHandlingEnabledQueriesTest.java
+++
b/pinot-core/src/test/java/org/apache/pinot/queries/NullHandlingEnabledQueriesTest.java
@@ -82,6 +82,7 @@ public class NullHandlingEnabledQueriesTest extends
BaseQueriesTest {
.setNoDictionaryColumns(List.of(COLUMN1))
.setRangeIndexColumns(List.of(COLUMN1))
.build();
+ private static final TableConfig TABLE_CONFIG_WITH_LEGACY_RANGE_INDEX_COLUMN
= getTableConfigWithLegacyRangeIndex();
private static final int NUM_OF_SEGMENT_COPIES = 4;
private static final Map<String, String> QUERY_OPTIONS =
Map.of("enableNullHandling", "true");
@@ -382,6 +383,72 @@ public class NullHandlingEnabledQueriesTest extends
BaseQueriesTest {
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);
+
+ // Rows 4 to 29 hold a value above 4
+ assertEquals(getRows(String.format("SELECT COUNT(*) FROM testTable WHERE
%s > 4", COLUMN1)).get(0)[0],
+ (long) 26 * NUM_OF_SEGMENT_COPIES);
+ // Rows 0 to 3 hold no value above 4, and the null row is UNKNOWN
+ assertEquals(getRows(String.format("SELECT COUNT(*) FROM testTable WHERE
NOT (%s > 4)", COLUMN1)).get(0)[0],
+ (long) 4 * NUM_OF_SEGMENT_COPIES);
+ // Rows 4 to 20 hold a value from 5 to 20
+ assertEquals(
+ getRows(String.format("SELECT COUNT(*) FROM testTable WHERE %s BETWEEN
5 AND 20", COLUMN1)).get(0)[0],
+ (long) 17 * NUM_OF_SEGMENT_COPIES);
+ // Rows 0 to 4 hold a value below 5. The default value stored for the null
row is below 5 as well, so this checks
+ // that the null row is left out of the combined result.
+ assertEquals(getRows(String.format("SELECT COUNT(*) FROM testTable WHERE
%s < 5", COLUMN1)).get(0)[0],
+ (long) 5 * NUM_OF_SEGMENT_COPIES);
+ }
+
+ /// A single-value column gets the legacy range index when the table sets
`rangeIndexVersion` to 1, and goes through
+ /// the same partial range scan as a multi-value column.
+ @Test
+ public void testRangeFilterOnSingleValueColumnWithLegacyRangeIndex()
+ throws Exception {
+ initializeRows();
+ for (int i = 0; i < 30; i++) {
+ insertRow(i);
+ }
+ insertRow(null);
+ Schema schema = schemaBuilder().addSingleValueDimension(COLUMN1,
DataType.INT).build();
+ setUpSegments(TABLE_CONFIG_WITH_LEGACY_RANGE_INDEX_COLUMN, schema);
+
+ // Rows 5 to 29 hold a value above 4
+ assertEquals(getRows(String.format("SELECT COUNT(*) FROM testTable WHERE
%s > 4", COLUMN1)).get(0)[0],
+ (long) 25 * NUM_OF_SEGMENT_COPIES);
+ // Rows 0 to 4 hold a value of at most 4, and the null row is UNKNOWN
+ assertEquals(getRows(String.format("SELECT COUNT(*) FROM testTable WHERE
NOT (%s > 4)", COLUMN1)).get(0)[0],
+ (long) 5 * NUM_OF_SEGMENT_COPIES);
+ // Rows 5 to 20 hold a value from 5 to 20
+ assertEquals(
+ getRows(String.format("SELECT COUNT(*) FROM testTable WHERE %s BETWEEN
5 AND 20", COLUMN1)).get(0)[0],
+ (long) 16 * NUM_OF_SEGMENT_COPIES);
+ // Rows 0 to 4 hold a value below 5. The default value stored for the null
row is below 5 as well, so this checks
+ // that the null row is left out of the combined result.
+ assertEquals(getRows(String.format("SELECT COUNT(*) FROM testTable WHERE
%s < 5", COLUMN1)).get(0)[0],
+ (long) 5 * NUM_OF_SEGMENT_COPIES);
+ }
+
+ private static TableConfig getTableConfigWithLegacyRangeIndex() {
+ TableConfig tableConfig = new
TableConfigBuilder(TableType.OFFLINE).setTableName(RAW_TABLE_NAME)
+ .setRangeIndexColumns(List.of(COLUMN1))
+ .build();
+ tableConfig.getIndexingConfig().setRangeIndexVersion(1);
+ return tableConfig;
+ }
+
/// A consuming segment reports its null rows through a vector that grows
with ingestion and hands out a copy on each
/// read. The filter takes that copy once, and the index-based count has to
leave those rows out as on a sealed
/// segment.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]