Skip to content

Commit

Permalink
[fix](inverted index) Fix errors caused by enable_need_read_data_opt (#…
Browse files Browse the repository at this point in the history
…42064) (#42362)

## Proposed changes

pick from master #42064
  • Loading branch information
csun5285 authored Oct 24, 2024
1 parent bf0a1fb commit ea07a39
Show file tree
Hide file tree
Showing 3 changed files with 160 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ public List<Rule> buildRules() {
Set<Slot> aggSlots = funcs.stream()
.flatMap(f -> f.getInputSlots().stream())
.collect(Collectors.toSet());
return conjuncts.stream().allMatch(expr -> checkSlotInOrExpression(expr, aggSlots));
return conjuncts.stream().allMatch(expr -> checkSlotInOrExpression(expr, aggSlots)
&& checkIsNullExpr(expr, aggSlots));
})
.thenApply(ctx -> {
LogicalAggregate<LogicalFilter<LogicalOlapScan>> agg = ctx.root;
Expand Down Expand Up @@ -166,7 +167,8 @@ public List<Rule> buildRules() {
Set<Slot> aggSlots = funcs.stream()
.flatMap(f -> f.getInputSlots().stream())
.collect(Collectors.toSet());
return conjuncts.stream().allMatch(expr -> checkSlotInOrExpression(expr, aggSlots));
return conjuncts.stream().allMatch(expr -> checkSlotInOrExpression(expr, aggSlots)
&& checkIsNullExpr(expr, aggSlots));
})
.thenApply(ctx -> {
LogicalAggregate<LogicalProject<LogicalFilter<LogicalOlapScan>>> agg = ctx.root;
Expand Down Expand Up @@ -373,6 +375,22 @@ private boolean checkSlotInOrExpression(Expression expr, Set<Slot> aggSlots) {
return true;
}

private boolean checkIsNullExpr(Expression expr, Set<Slot> aggSlots) {
if (expr instanceof IsNull) {
Set<Slot> slots = expr.getInputSlots();
if (slots.stream().anyMatch(aggSlots::contains)) {
return false;
}
} else {
for (Expression child : expr.children()) {
if (!checkIsNullExpr(child, aggSlots)) {
return false;
}
}
}
return true;
}

private boolean isDupOrMowKeyTable(LogicalOlapScan logicalScan) {
if (logicalScan != null) {
KeysType keysType = logicalScan.getTable().getKeysType();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !sql --
0

136 changes: 136 additions & 0 deletions regression-test/suites/inverted_index_p0/test_index_rqg_bug8.groovy

Large diffs are not rendered by default.

0 comments on commit ea07a39

Please sign in to comment.