-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support creating dictionary at runtime for an existing column #9678
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -223,6 +223,42 @@ public void testSelectionOverRangeFilter(String query, int min, int max, boolean | |
} | ||
} | ||
|
||
@Test(dataProvider = "selectionTestCases") | ||
public void testSelectionOverRangeFilterAfterReload(String query, int min, int max, boolean inclusive) | ||
throws Exception { | ||
// Enable dictionary on RAW_INT_COL and reload the segment. | ||
IndexLoadingConfig indexLoadingConfig = new IndexLoadingConfig(null, TABLE_CONFIG); | ||
indexLoadingConfig.getNoDictionaryColumns().remove(RAW_INT_COL); | ||
File indexDir = new File(INDEX_DIR, SEGMENT_NAME); | ||
ImmutableSegment immutableSegment = reloadSegment(indexDir, indexLoadingConfig, SCHEMA); | ||
_indexSegment = immutableSegment; | ||
_indexSegments = Arrays.asList(immutableSegment, immutableSegment); | ||
|
||
Operator<?> operator = getOperator(query); | ||
assertTrue(operator instanceof SelectionOnlyOperator); | ||
for (Object[] row : Objects.requireNonNull(((SelectionOnlyOperator) operator).nextBlock().getRows())) { | ||
int value = (int) row[0]; | ||
assertTrue(inclusive ? value >= min : value > min); | ||
assertTrue(inclusive ? value <= max : value < max); | ||
} | ||
|
||
// Enable dictionary on RAW_DOUBLE_COL and reload the segment. | ||
indexLoadingConfig = new IndexLoadingConfig(null, TABLE_CONFIG); | ||
indexLoadingConfig.getNoDictionaryColumns().remove(RAW_DOUBLE_COL); | ||
indexDir = new File(INDEX_DIR, SEGMENT_NAME); | ||
immutableSegment = reloadSegment(indexDir, indexLoadingConfig, SCHEMA); | ||
_indexSegment = immutableSegment; | ||
_indexSegments = Arrays.asList(immutableSegment, immutableSegment); | ||
|
||
operator = getOperator(query); | ||
assertTrue(operator instanceof SelectionOnlyOperator); | ||
for (Object[] row : Objects.requireNonNull(((SelectionOnlyOperator) operator).nextBlock().getRows())) { | ||
int value = (int) row[0]; | ||
assertTrue(inclusive ? value >= min : value > min); | ||
assertTrue(inclusive ? value <= max : value < max); | ||
} | ||
} | ||
|
||
@Test(dataProvider = "countTestCases") | ||
public void testCountOverRangeFilter(String query, int expectedCount) { | ||
Operator<?> operator = getOperator(query); | ||
|
@@ -232,4 +268,38 @@ public void testCountOverRangeFilter(String query, int expectedCount) { | |
assertEquals(aggregationResult.size(), 1); | ||
assertEquals(((Number) aggregationResult.get(0)).intValue(), expectedCount, query); | ||
} | ||
|
||
@Test(dataProvider = "countTestCases") | ||
public void testCountOverRangeFilterAfterReload(String query, int expectedCount) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Best for us to control the query. Not really sure if the query being sent here by the provider is indeed using the concerned column in parts where we want There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
throws Exception { | ||
// Enable dictionary on RAW_LONG_COL and reload the segment. | ||
IndexLoadingConfig indexLoadingConfig = new IndexLoadingConfig(null, TABLE_CONFIG); | ||
indexLoadingConfig.getNoDictionaryColumns().remove(RAW_LONG_COL); | ||
File indexDir = new File(INDEX_DIR, SEGMENT_NAME); | ||
ImmutableSegment immutableSegment = reloadSegment(indexDir, indexLoadingConfig, SCHEMA); | ||
_indexSegment = immutableSegment; | ||
_indexSegments = Arrays.asList(immutableSegment, immutableSegment); | ||
|
||
|
||
Operator<?> operator = getOperator(query); | ||
assertTrue(operator instanceof FastFilteredCountOperator); | ||
List<Object> aggregationResult = ((FastFilteredCountOperator) operator).nextBlock().getResults(); | ||
assertNotNull(aggregationResult); | ||
assertEquals(aggregationResult.size(), 1); | ||
assertEquals(((Number) aggregationResult.get(0)).intValue(), expectedCount, query); | ||
|
||
// Enable dictionary on RAW_FLOAT_COL and reload the segment. | ||
indexLoadingConfig = new IndexLoadingConfig(null, TABLE_CONFIG); | ||
indexLoadingConfig.getNoDictionaryColumns().remove(RAW_FLOAT_COL); | ||
immutableSegment = reloadSegment(indexDir, indexLoadingConfig, SCHEMA); | ||
_indexSegment = immutableSegment; | ||
_indexSegments = Arrays.asList(immutableSegment, immutableSegment); | ||
|
||
operator = getOperator(query); | ||
assertTrue(operator instanceof FastFilteredCountOperator); | ||
aggregationResult = ((FastFilteredCountOperator) operator).nextBlock().getResults(); | ||
assertNotNull(aggregationResult); | ||
assertEquals(aggregationResult.size(), 1); | ||
assertEquals(((Number) aggregationResult.get(0)).intValue(), expectedCount, query); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Query execution tests seem to be focused on range index only. Any reason ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should add other tests like
Same goes for using the column in SELECT clause. It should correctly return the same result after doing dual lookup in rewriten fwd index and dict as it did before with raw fwd index. Things like that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple of types for both SV and MV should be considered