Skip to content

Commit

Permalink
fix PushDownFilterThroughSetOperation
Browse files Browse the repository at this point in the history
  • Loading branch information
feiniaofeiafei committed Jan 3, 2025
1 parent 073fd68 commit 22e4162
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,16 @@ public Rule build() {
return logicalFilter(logicalSetOperation()).then(f -> {
LogicalSetOperation setOperation = f.child();
List<Plan> newChildren = new ArrayList<>();
for (Plan child : setOperation.children()) {
for (int childIdx = 0; childIdx < setOperation.children().size(); ++childIdx) {
Map<Expression, Expression> replaceMap = new HashMap<>();
for (int i = 0; i < setOperation.getOutputs().size(); ++i) {
NamedExpression output = setOperation.getOutputs().get(i);
replaceMap.put(output, child.getOutput().get(i));
replaceMap.put(output, setOperation.getRegularChildOutput(childIdx).get(i));
}

Set<Expression> newFilterPredicates = f.getConjuncts().stream().map(conjunct ->
ExpressionUtils.replace(conjunct, replaceMap)).collect(ImmutableSet.toImmutableSet());
newChildren.add(new LogicalFilter<>(newFilterPredicates, child));
newChildren.add(new LogicalFilter<>(newFilterPredicates, setOperation.child(childIdx)));
}

return setOperation.withChildren(newChildren);
Expand Down

0 comments on commit 22e4162

Please sign in to comment.