[fix](Nereids) expressions is not be extracted when binding function (#15361)

This commit is contained in:
mch_ucchi
2022-12-27 17:12:07 +08:00
committed by GitHub
parent a07ca41f8e
commit 849adca225

View File

@ -49,10 +49,10 @@ import org.apache.doris.nereids.trees.plans.logical.LogicalSort;
import org.apache.doris.nereids.trees.plans.logical.LogicalTVFRelation;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import java.util.List;
import java.util.Locale;
import java.util.Set;
import java.util.stream.Collectors;
/**
@ -102,15 +102,15 @@ public class BindFunction implements AnalysisRuleFactory {
RuleType.BINDING_FILTER_FUNCTION.build(
logicalFilter().thenApply(ctx -> {
LogicalFilter<GroupPlan> filter = ctx.root;
List<Expression> conjuncts = bind(filter.getExpressions(), ctx.connectContext.getEnv());
return new LogicalFilter<>(ImmutableSet.copyOf(conjuncts), filter.child());
Set<Expression> conjuncts = bind(filter.getConjuncts(), ctx.connectContext.getEnv());
return new LogicalFilter<>(conjuncts, filter.child());
})
),
RuleType.BINDING_HAVING_FUNCTION.build(
logicalHaving().thenApply(ctx -> {
LogicalHaving<GroupPlan> having = ctx.root;
List<Expression> conjuncts = bind(having.getExpressions(), ctx.connectContext.getEnv());
return new LogicalHaving<>(ImmutableSet.copyOf(conjuncts), having.child());
Set<Expression> conjuncts = bind(having.getConjuncts(), ctx.connectContext.getEnv());
return new LogicalHaving<>(conjuncts, having.child());
})
),
RuleType.BINDING_SORT_FUNCTION.build(
@ -151,6 +151,12 @@ public class BindFunction implements AnalysisRuleFactory {
.collect(Collectors.toList());
}
private <E extends Expression> Set<E> bind(Set<? extends E> exprSet, Env env) {
return exprSet.stream()
.map(expr -> FunctionBinder.INSTANCE.bind(expr, env))
.collect(Collectors.toSet());
}
/**
* function binder
*/