[optimize](planner)remove redundant conjuncts on plan node (#9819)
This commit is contained in:
@ -375,14 +375,18 @@ abstract public class PlanNode extends TreeNode<PlanNode> {
|
||||
if (conjuncts == null) {
|
||||
return;
|
||||
}
|
||||
this.conjuncts.addAll(conjuncts);
|
||||
for (Expr conjunct : conjuncts) {
|
||||
addConjunct(conjunct);
|
||||
}
|
||||
}
|
||||
|
||||
public void addConjunct(Expr conjunct) {
|
||||
if (conjuncts == null) {
|
||||
conjuncts = Lists.newArrayList();
|
||||
}
|
||||
conjuncts.add(conjunct);
|
||||
if (!conjuncts.contains(conjunct)) {
|
||||
conjuncts.add(conjunct);
|
||||
}
|
||||
}
|
||||
|
||||
public void setAssignedConjuncts(Set<ExprId> conjuncts) {
|
||||
@ -636,7 +640,9 @@ abstract public class PlanNode extends TreeNode<PlanNode> {
|
||||
*/
|
||||
protected void assignConjuncts(Analyzer analyzer) {
|
||||
List<Expr> unassigned = analyzer.getUnassignedConjuncts(this);
|
||||
conjuncts.addAll(unassigned);
|
||||
for (Expr unassignedConjunct : unassigned) {
|
||||
addConjunct(unassignedConjunct);
|
||||
}
|
||||
analyzer.markConjunctsAssigned(unassigned);
|
||||
}
|
||||
|
||||
|
||||
@ -25,6 +25,7 @@ import org.apache.doris.analysis.InPredicate;
|
||||
import org.apache.doris.analysis.LiteralExpr;
|
||||
import org.apache.doris.analysis.SlotRef;
|
||||
import org.apache.doris.common.AnalysisException;
|
||||
import org.apache.doris.planner.PlanNode;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.BoundType;
|
||||
@ -53,6 +54,11 @@ import java.util.Set;
|
||||
* -> (1<k1<4) and k2 in('Marry','Tom') and (1<k1<3 and k2 in ('Marry')) or (2<k1<4 and k2 in ('Tom'))
|
||||
*
|
||||
* The second rewriting can be controlled by session variable 'extract_wide_range_expr'
|
||||
*
|
||||
* TODO: extract wide common factors could generate redundant conjuncts when whole expression could be extracted.
|
||||
* Currently, redundant conjuncts will be removed when be assigned to {@link PlanNode}
|
||||
* by calling {@link PlanNode#addConjunct(Expr)}, {@link PlanNode#addConjuncts(List)}, {@link PlanNode#init(Analyzer)}.
|
||||
* But, we should remove redundant conjuncts generated by redundant conjuncts in this rule.
|
||||
*/
|
||||
public class ExtractCommonFactorsRule implements ExprRewriteRule {
|
||||
private final static Logger LOG = LogManager.getLogger(ExtractCommonFactorsRule.class);
|
||||
|
||||
Reference in New Issue
Block a user