[chore](Nereids): rename pushdown to push_down (#27473)

This commit is contained in:
jakevin
2023-11-23 21:04:40 +08:00
committed by GitHub
parent d04a2de3cc
commit d73b945535
53 changed files with 255 additions and 250 deletions

View File

@ -91,14 +91,14 @@ import org.apache.doris.nereids.rules.rewrite.PullUpProjectUnderLimit;
import org.apache.doris.nereids.rules.rewrite.PullUpProjectUnderTopN;
import org.apache.doris.nereids.rules.rewrite.PushConjunctsIntoEsScan;
import org.apache.doris.nereids.rules.rewrite.PushConjunctsIntoJdbcScan;
import org.apache.doris.nereids.rules.rewrite.PushDownFilterThroughProject;
import org.apache.doris.nereids.rules.rewrite.PushDownLimit;
import org.apache.doris.nereids.rules.rewrite.PushDownLimitDistinctThroughJoin;
import org.apache.doris.nereids.rules.rewrite.PushDownTopNThroughJoin;
import org.apache.doris.nereids.rules.rewrite.PushDownTopNThroughWindow;
import org.apache.doris.nereids.rules.rewrite.PushFilterInsideJoin;
import org.apache.doris.nereids.rules.rewrite.PushProjectIntoOneRowRelation;
import org.apache.doris.nereids.rules.rewrite.PushProjectThroughUnion;
import org.apache.doris.nereids.rules.rewrite.PushdownFilterThroughProject;
import org.apache.doris.nereids.rules.rewrite.PushdownLimit;
import org.apache.doris.nereids.rules.rewrite.PushdownLimitDistinctThroughJoin;
import org.apache.doris.nereids.rules.rewrite.PushdownTopNThroughJoin;
import org.apache.doris.nereids.rules.rewrite.PushdownTopNThroughWindow;
import org.apache.doris.nereids.rules.rewrite.ReorderJoin;
import org.apache.doris.nereids.rules.rewrite.RewriteCteChildren;
import org.apache.doris.nereids.rules.rewrite.SemiJoinCommute;
@ -152,7 +152,7 @@ public class Rewriter extends AbstractBatchJobExecutor {
// after doing NormalizeAggregate in analysis job
// we need run the following 2 rules to make AGG_SCALAR_SUBQUERY_TO_WINDOW_FUNCTION work
bottomUp(new PullUpProjectUnderApply()),
topDown(new PushdownFilterThroughProject()),
topDown(new PushDownFilterThroughProject()),
custom(RuleType.AGG_SCALAR_SUBQUERY_TO_WINDOW_FUNCTION,
AggScalarSubQueryToWindowFunction::new),
bottomUp(
@ -236,13 +236,13 @@ public class Rewriter extends AbstractBatchJobExecutor {
topDown(new ConvertInnerOrCrossJoin())
),
topic("LEADING JOIN",
bottomUp(
new CollectJoinConstraint()
),
custom(RuleType.LEADING_JOIN, LeadingJoin::new),
bottomUp(
new ExpressionRewrite(CheckLegalityAfterRewrite.INSTANCE)
)
bottomUp(
new CollectJoinConstraint()
),
custom(RuleType.LEADING_JOIN, LeadingJoin::new),
bottomUp(
new ExpressionRewrite(CheckLegalityAfterRewrite.INSTANCE)
)
),
topic("Column pruning and infer predicate",
custom(RuleType.COLUMN_PRUNING, ColumnPruning::new),
@ -272,8 +272,13 @@ public class Rewriter extends AbstractBatchJobExecutor {
topDown(new BuildAggForUnion())
),
// topic("Distinct",
// costBased(custom(RuleType.PUSH_DOWN_DISTINCT_THROUGH_JOIN, PushdownDistinctThroughJoin::new))
// topic("Eager aggregation",
// topDown(
// new PushDownSumThroughJoin(),
// new PushDownMinMaxThroughJoin(),
// new PushDownCountThroughJoin()
// ),
// custom(RuleType.PUSH_DOWN_DISTINCT_THROUGH_JOIN, PushDownDistinctThroughJoin::new)
// ),
topic("Limit optimization",
@ -284,10 +289,10 @@ public class Rewriter extends AbstractBatchJobExecutor {
topDown(new LimitSortToTopN()),
topDown(new SplitLimit()),
topDown(
new PushdownLimit(),
new PushdownTopNThroughJoin(),
new PushdownLimitDistinctThroughJoin(),
new PushdownTopNThroughWindow()
new PushDownLimit(),
new PushDownTopNThroughJoin(),
new PushDownLimitDistinctThroughJoin(),
new PushDownTopNThroughWindow()
),
topDown(new CreatePartitionTopNFromWindow()),
topDown(
@ -310,7 +315,7 @@ public class Rewriter extends AbstractBatchJobExecutor {
new SelectMaterializedIndexWithAggregate(),
new SelectMaterializedIndexWithoutAggregate(),
new EliminateFilter(),
new PushdownFilterThroughProject(),
new PushDownFilterThroughProject(),
new MergeProjects(),
new PruneOlapScanTablet()
),
@ -330,7 +335,7 @@ public class Rewriter extends AbstractBatchJobExecutor {
topic("Final rewrite and check",
custom(RuleType.CHECK_DATA_TYPES, CheckDataTypes::new),
custom(RuleType.ENSURE_PROJECT_ON_TOP_JOIN, EnsureProjectOnTopJoin::new),
topDown(new PushdownFilterThroughProject(), new MergeProjects()),
topDown(new PushDownFilterThroughProject(), new MergeProjects()),
custom(RuleType.ADJUST_CONJUNCTS_RETURN_TYPE, AdjustConjunctsReturnType::new),
bottomUp(
new ExpressionRewrite(CheckLegalityAfterRewrite.INSTANCE),
@ -378,8 +383,8 @@ public class Rewriter extends AbstractBatchJobExecutor {
private static List<RewriteJob> getWholeTreeRewriteJobs(boolean withCostBased) {
List<RewriteJob> withoutCostBased = Rewriter.CTE_CHILDREN_REWRITE_JOBS.stream()
.filter(j -> !(j instanceof CostBasedRewriteJob))
.collect(Collectors.toList());
.filter(j -> !(j instanceof CostBasedRewriteJob))
.collect(Collectors.toList());
return getWholeTreeRewriteJobs(withCostBased ? CTE_CHILDREN_REWRITE_JOBS : withoutCostBased);
}

View File

@ -58,7 +58,7 @@ public class PlanPostProcessors {
public List<PlanPostProcessor> getProcessors() {
// add processor if we need
Builder<PlanPostProcessor> builder = ImmutableList.builder();
builder.add(new PushdownFilterThroughProject());
builder.add(new PushDownFilterThroughProject());
builder.add(new MergeProjectPostProcessor());
builder.add(new RecomputeLogicalPropertiesProcessor());
builder.add(new TopNScanOpt());

View File

@ -27,7 +27,7 @@ import org.apache.doris.nereids.util.ExpressionUtils;
/**
* merge consecutive projects
*/
public class PushdownFilterThroughProject extends PlanPostProcessor {
public class PushDownFilterThroughProject extends PlanPostProcessor {
@Override
public Plan visitPhysicalFilter(PhysicalFilter<? extends Plan> filter, CascadesContext context) {
Plan child = filter.child();

View File

@ -36,8 +36,8 @@ import org.apache.doris.nereids.rules.exploration.join.OuterJoinAssoc;
import org.apache.doris.nereids.rules.exploration.join.OuterJoinAssocProject;
import org.apache.doris.nereids.rules.exploration.join.OuterJoinLAsscom;
import org.apache.doris.nereids.rules.exploration.join.OuterJoinLAsscomProject;
import org.apache.doris.nereids.rules.exploration.join.PushdownProjectThroughInnerOuterJoin;
import org.apache.doris.nereids.rules.exploration.join.PushdownProjectThroughSemiJoin;
import org.apache.doris.nereids.rules.exploration.join.PushDownProjectThroughInnerOuterJoin;
import org.apache.doris.nereids.rules.exploration.join.PushDownProjectThroughSemiJoin;
import org.apache.doris.nereids.rules.exploration.join.SemiJoinSemiJoinTranspose;
import org.apache.doris.nereids.rules.exploration.join.SemiJoinSemiJoinTransposeProject;
import org.apache.doris.nereids.rules.implementation.AggregateStrategies;
@ -80,18 +80,18 @@ import org.apache.doris.nereids.rules.rewrite.MergeFilters;
import org.apache.doris.nereids.rules.rewrite.MergeGenerates;
import org.apache.doris.nereids.rules.rewrite.MergeLimits;
import org.apache.doris.nereids.rules.rewrite.MergeProjects;
import org.apache.doris.nereids.rules.rewrite.PushdownAliasThroughJoin;
import org.apache.doris.nereids.rules.rewrite.PushdownExpressionsInHashCondition;
import org.apache.doris.nereids.rules.rewrite.PushdownFilterThroughAggregation;
import org.apache.doris.nereids.rules.rewrite.PushdownFilterThroughJoin;
import org.apache.doris.nereids.rules.rewrite.PushdownFilterThroughPartitionTopN;
import org.apache.doris.nereids.rules.rewrite.PushdownFilterThroughProject;
import org.apache.doris.nereids.rules.rewrite.PushdownFilterThroughRepeat;
import org.apache.doris.nereids.rules.rewrite.PushdownFilterThroughSetOperation;
import org.apache.doris.nereids.rules.rewrite.PushdownFilterThroughSort;
import org.apache.doris.nereids.rules.rewrite.PushdownFilterThroughWindow;
import org.apache.doris.nereids.rules.rewrite.PushdownJoinOtherCondition;
import org.apache.doris.nereids.rules.rewrite.PushdownProjectThroughLimit;
import org.apache.doris.nereids.rules.rewrite.PushDownAliasThroughJoin;
import org.apache.doris.nereids.rules.rewrite.PushDownExpressionsInHashCondition;
import org.apache.doris.nereids.rules.rewrite.PushDownFilterThroughAggregation;
import org.apache.doris.nereids.rules.rewrite.PushDownFilterThroughJoin;
import org.apache.doris.nereids.rules.rewrite.PushDownFilterThroughPartitionTopN;
import org.apache.doris.nereids.rules.rewrite.PushDownFilterThroughProject;
import org.apache.doris.nereids.rules.rewrite.PushDownFilterThroughRepeat;
import org.apache.doris.nereids.rules.rewrite.PushDownFilterThroughSetOperation;
import org.apache.doris.nereids.rules.rewrite.PushDownFilterThroughSort;
import org.apache.doris.nereids.rules.rewrite.PushDownFilterThroughWindow;
import org.apache.doris.nereids.rules.rewrite.PushDownJoinOtherCondition;
import org.apache.doris.nereids.rules.rewrite.PushDownProjectThroughLimit;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableList.Builder;
@ -115,8 +115,8 @@ public class RuleSet {
.add(SemiJoinSemiJoinTransposeProject.INSTANCE)
.add(LogicalJoinSemiJoinTranspose.INSTANCE)
.add(LogicalJoinSemiJoinTransposeProject.INSTANCE)
.add(PushdownProjectThroughInnerOuterJoin.INSTANCE)
.add(PushdownProjectThroughSemiJoin.INSTANCE)
.add(PushDownProjectThroughInnerOuterJoin.INSTANCE)
.add(PushDownProjectThroughSemiJoin.INSTANCE)
.add(TransposeAggSemiJoin.INSTANCE)
.add(TransposeAggSemiJoinProject.INSTANCE)
.add(OrExpansion.INSTANCE)
@ -124,24 +124,24 @@ public class RuleSet {
public static final List<RuleFactory> PUSH_DOWN_FILTERS = ImmutableList.of(
new CreatePartitionTopNFromWindow(),
new PushdownFilterThroughProject(),
new PushdownFilterThroughSort(),
new PushdownJoinOtherCondition(),
new PushdownFilterThroughJoin(),
new PushdownExpressionsInHashCondition(),
new PushdownFilterThroughAggregation(),
new PushdownFilterThroughRepeat(),
new PushdownFilterThroughSetOperation(),
new PushdownProjectThroughLimit(),
new PushDownFilterThroughProject(),
new PushDownFilterThroughSort(),
new PushDownJoinOtherCondition(),
new PushDownFilterThroughJoin(),
new PushDownExpressionsInHashCondition(),
new PushDownFilterThroughAggregation(),
new PushDownFilterThroughRepeat(),
new PushDownFilterThroughSetOperation(),
new PushDownProjectThroughLimit(),
new EliminateOuterJoin(),
new ConvertOuterJoinToAntiJoin(),
new MergeProjects(),
new MergeFilters(),
new MergeGenerates(),
new MergeLimits(),
new PushdownAliasThroughJoin(),
new PushdownFilterThroughWindow(),
new PushdownFilterThroughPartitionTopN()
new PushDownAliasThroughJoin(),
new PushDownFilterThroughWindow(),
new PushDownFilterThroughPartitionTopN()
);
public static final List<Rule> IMPLEMENTATION_RULES = planRuleFactories()

View File

@ -142,35 +142,35 @@ public enum RuleType {
IN_APPLY_TO_JOIN(RuleTypeClass.REWRITE),
EXISTS_APPLY_TO_JOIN(RuleTypeClass.REWRITE),
// predicate push down rules
PUSHDOWN_JOIN_OTHER_CONDITION(RuleTypeClass.REWRITE),
PUSHDOWN_PREDICATE_THROUGH_AGGREGATION(RuleTypeClass.REWRITE),
PUSHDOWN_PREDICATE_THROUGH_REPEAT(RuleTypeClass.REWRITE),
PUSHDOWN_EXPRESSIONS_IN_HASH_CONDITIONS(RuleTypeClass.REWRITE),
PUSH_DOWN_JOIN_OTHER_CONDITION(RuleTypeClass.REWRITE),
PUSH_DOWN_PREDICATE_THROUGH_AGGREGATION(RuleTypeClass.REWRITE),
PUSH_DOWN_PREDICATE_THROUGH_REPEAT(RuleTypeClass.REWRITE),
PUSH_DOWN_EXPRESSIONS_IN_HASH_CONDITIONS(RuleTypeClass.REWRITE),
// Pushdown filter
PUSHDOWN_FILTER_THROUGH_JOIN(RuleTypeClass.REWRITE),
PUSHDOWN_FILTER_THROUGH_LEFT_SEMI_JOIN(RuleTypeClass.REWRITE),
PUSH_DOWN_FILTER_THROUGH_JOIN(RuleTypeClass.REWRITE),
PUSH_DOWN_FILTER_THROUGH_LEFT_SEMI_JOIN(RuleTypeClass.REWRITE),
PUSH_FILTER_INSIDE_JOIN(RuleTypeClass.REWRITE),
PUSHDOWN_FILTER_THROUGH_PROJECT(RuleTypeClass.REWRITE),
PUSHDOWN_FILTER_THROUGH_PROJECT_UNDER_LIMIT(RuleTypeClass.REWRITE),
PUSHDOWN_FILTER_THROUGH_WINDOW(RuleTypeClass.REWRITE),
PUSHDOWN_FILTER_THROUGH_PARTITION_TOPN(RuleTypeClass.REWRITE),
PUSHDOWN_PROJECT_THROUGH_LIMIT(RuleTypeClass.REWRITE),
PUSHDOWN_ALIAS_THROUGH_JOIN(RuleTypeClass.REWRITE),
PUSHDOWN_ALIAS_INTO_UNION_ALL(RuleTypeClass.REWRITE),
PUSHDOWN_FILTER_THROUGH_SET_OPERATION(RuleTypeClass.REWRITE),
PUSHDOWN_FILTER_THROUGH_SORT(RuleTypeClass.REWRITE),
PUSH_DOWN_FILTER_THROUGH_PROJECT(RuleTypeClass.REWRITE),
PUSH_DOWN_FILTER_THROUGH_PROJECT_UNDER_LIMIT(RuleTypeClass.REWRITE),
PUSH_DOWN_FILTER_THROUGH_WINDOW(RuleTypeClass.REWRITE),
PUSH_DOWN_FILTER_THROUGH_PARTITION_TOPN(RuleTypeClass.REWRITE),
PUSH_DOWN_PROJECT_THROUGH_LIMIT(RuleTypeClass.REWRITE),
PUSH_DOWN_ALIAS_THROUGH_JOIN(RuleTypeClass.REWRITE),
PUSH_DOWN_ALIAS_INTO_UNION_ALL(RuleTypeClass.REWRITE),
PUSH_DOWN_FILTER_THROUGH_SET_OPERATION(RuleTypeClass.REWRITE),
PUSH_DOWN_FILTER_THROUGH_SORT(RuleTypeClass.REWRITE),
PUSHDOWN_FILTER_THROUGH_CTE(RuleTypeClass.REWRITE),
PUSHDOWN_FILTER_THROUGH_CTE_ANCHOR(RuleTypeClass.REWRITE),
PUSH_DOWN_FILTER_THROUGH_CTE(RuleTypeClass.REWRITE),
PUSH_DOWN_FILTER_THROUGH_CTE_ANCHOR(RuleTypeClass.REWRITE),
PUSHDOWN_DISTINCT_THROUGH_JOIN(RuleTypeClass.REWRITE),
PUSH_DOWN_DISTINCT_THROUGH_JOIN(RuleTypeClass.REWRITE),
COLUMN_PRUNING(RuleTypeClass.REWRITE),
ELIMINATE_SORT(RuleTypeClass.REWRITE),
PUSHDOWN_MIN_MAX_THROUGH_JOIN(RuleTypeClass.REWRITE),
PUSHDOWN_SUM_THROUGH_JOIN(RuleTypeClass.REWRITE),
PUSHDOWN_COUNT_THROUGH_JOIN(RuleTypeClass.REWRITE),
PUSH_DOWN_MIN_MAX_THROUGH_JOIN(RuleTypeClass.REWRITE),
PUSH_DOWN_SUM_THROUGH_JOIN(RuleTypeClass.REWRITE),
PUSH_DOWN_COUNT_THROUGH_JOIN(RuleTypeClass.REWRITE),
TRANSPOSE_LOGICAL_SEMI_JOIN_LOGICAL_JOIN(RuleTypeClass.REWRITE),
TRANSPOSE_LOGICAL_SEMI_JOIN_LOGICAL_JOIN_PROJECT(RuleTypeClass.REWRITE),
@ -311,10 +311,10 @@ public enum RuleType {
TRANSPOSE_LOGICAL_AGG_SEMI_JOIN(RuleTypeClass.EXPLORATION),
TRANSPOSE_LOGICAL_AGG_SEMI_JOIN_PROJECT(RuleTypeClass.EXPLORATION),
TRANSPOSE_LOGICAL_JOIN_UNION(RuleTypeClass.EXPLORATION),
PUSHDOWN_PROJECT_THROUGH_SEMI_JOIN_LEFT(RuleTypeClass.EXPLORATION),
PUSHDOWN_PROJECT_THROUGH_SEMI_JOIN_RIGHT(RuleTypeClass.EXPLORATION),
PUSHDOWN_PROJECT_THROUGH_INNER_OUTER_JOIN_LEFT(RuleTypeClass.EXPLORATION),
PUSHDOWN_PROJECT_THROUGH_INNER_OUTER_JOIN_RIGHT(RuleTypeClass.EXPLORATION),
PUSH_DOWN_PROJECT_THROUGH_SEMI_JOIN_LEFT(RuleTypeClass.EXPLORATION),
PUSH_DOWN_PROJECT_THROUGH_SEMI_JOIN_RIGHT(RuleTypeClass.EXPLORATION),
PUSH_DOWN_PROJECT_THROUGH_INNER_OUTER_JOIN_LEFT(RuleTypeClass.EXPLORATION),
PUSH_DOWN_PROJECT_THROUGH_INNER_OUTER_JOIN_RIGHT(RuleTypeClass.EXPLORATION),
EAGER_COUNT(RuleTypeClass.EXPLORATION),
EAGER_GROUP_BY(RuleTypeClass.EXPLORATION),
EAGER_GROUP_BY_COUNT(RuleTypeClass.EXPLORATION),

View File

@ -21,7 +21,7 @@ import org.apache.doris.common.Pair;
import org.apache.doris.nereids.CascadesContext;
import org.apache.doris.nereids.rules.Rule;
import org.apache.doris.nereids.rules.RuleType;
import org.apache.doris.nereids.rules.rewrite.PushdownExpressionsInHashCondition;
import org.apache.doris.nereids.rules.rewrite.PushDownExpressionsInHashCondition;
import org.apache.doris.nereids.trees.expressions.Alias;
import org.apache.doris.nereids.trees.expressions.Expression;
import org.apache.doris.nereids.trees.expressions.NamedExpression;
@ -178,7 +178,7 @@ public class OrExpansion extends OneExplorationRuleFactory {
otherConditions, originJoin.getHint(),
originJoin.getMarkJoinSlotReference(), left, right);
if (hashCond.children().stream().anyMatch(e -> !(e instanceof Slot))) {
Plan normalizedPlan = PushdownExpressionsInHashCondition.pushDownHashExpression(
Plan normalizedPlan = PushDownExpressionsInHashCondition.pushDownHashExpression(
(LogicalJoin<? extends Plan, ? extends Plan>) newPlan);
newPlan = new LogicalProject<>(new ArrayList<>(newPlan.getOutput()), normalizedPlan);
}
@ -195,7 +195,7 @@ public class OrExpansion extends OneExplorationRuleFactory {
new ArrayList<>(), originJoin.getHint(),
originJoin.getMarkJoinSlotReference(), newPlan, newRight);
if (hashCond.children().stream().anyMatch(e -> !(e instanceof Slot))) {
newPlan = PushdownExpressionsInHashCondition.pushDownHashExpression(
newPlan = PushDownExpressionsInHashCondition.pushDownHashExpression(
(LogicalJoin<? extends Plan, ? extends Plan>) newPlan);
}
}
@ -252,7 +252,7 @@ public class OrExpansion extends OneExplorationRuleFactory {
join.getMarkJoinSlotReference(), left, right);
if (newJoin.getHashJoinConjuncts().stream()
.anyMatch(equalTo -> equalTo.children().stream().anyMatch(e -> !(e instanceof Slot)))) {
Plan plan = PushdownExpressionsInHashCondition.pushDownHashExpression(newJoin);
Plan plan = PushDownExpressionsInHashCondition.pushDownHashExpression(newJoin);
plan = new LogicalProject<>(new ArrayList<>(newJoin.getOutput()), plan);
joins.add(plan);
} else {

View File

@ -50,8 +50,8 @@ import java.util.stream.Collectors;
* A B A B
* </pre>
*/
public class PushdownProjectThroughInnerOuterJoin implements ExplorationRuleFactory {
public static final PushdownProjectThroughInnerOuterJoin INSTANCE = new PushdownProjectThroughInnerOuterJoin();
public class PushDownProjectThroughInnerOuterJoin implements ExplorationRuleFactory {
public static final PushDownProjectThroughInnerOuterJoin INSTANCE = new PushDownProjectThroughInnerOuterJoin();
@Override
public List<Rule> buildRules() {
@ -69,7 +69,7 @@ public class PushdownProjectThroughInnerOuterJoin implements ExplorationRuleFact
return null;
}
return topJoin.withChildren(newLeft, topJoin.right());
}).toRule(RuleType.PUSHDOWN_PROJECT_THROUGH_INNER_OUTER_JOIN_LEFT),
}).toRule(RuleType.PUSH_DOWN_PROJECT_THROUGH_INNER_OUTER_JOIN_LEFT),
logicalJoin(group(), logicalProject(logicalJoin().whenNot(LogicalJoin::isMarkJoin)))
.when(j -> j.right().child().getJoinType().isOuterJoin()
|| j.right().child().getJoinType().isInnerJoin())
@ -83,7 +83,7 @@ public class PushdownProjectThroughInnerOuterJoin implements ExplorationRuleFact
return null;
}
return topJoin.withChildren(topJoin.left(), newRight);
}).toRule(RuleType.PUSHDOWN_PROJECT_THROUGH_INNER_OUTER_JOIN_RIGHT)
}).toRule(RuleType.PUSH_DOWN_PROJECT_THROUGH_INNER_OUTER_JOIN_RIGHT)
);
}

View File

@ -48,8 +48,8 @@ import java.util.stream.Collectors;
* A B A
* </pre>
*/
public class PushdownProjectThroughSemiJoin implements ExplorationRuleFactory {
public static final PushdownProjectThroughSemiJoin INSTANCE = new PushdownProjectThroughSemiJoin();
public class PushDownProjectThroughSemiJoin implements ExplorationRuleFactory {
public static final PushDownProjectThroughSemiJoin INSTANCE = new PushDownProjectThroughSemiJoin();
@Override
public List<Rule> buildRules() {
@ -63,7 +63,7 @@ public class PushdownProjectThroughSemiJoin implements ExplorationRuleFactory {
LogicalProject<LogicalJoin<GroupPlan, GroupPlan>> project = topJoin.left();
Plan newLeft = pushdownProject(project);
return topJoin.withChildren(newLeft, topJoin.right());
}).toRule(RuleType.PUSHDOWN_PROJECT_THROUGH_SEMI_JOIN_LEFT),
}).toRule(RuleType.PUSH_DOWN_PROJECT_THROUGH_SEMI_JOIN_LEFT),
logicalJoin(group(), logicalProject(logicalJoin().whenNot(LogicalJoin::isMarkJoin)))
.when(j -> j.right().child().getJoinType().isLeftSemiOrAntiJoin())
@ -74,7 +74,7 @@ public class PushdownProjectThroughSemiJoin implements ExplorationRuleFactory {
LogicalProject<LogicalJoin<GroupPlan, GroupPlan>> project = topJoin.right();
Plan newRight = pushdownProject(project);
return topJoin.withChildren(topJoin.left(), newRight);
}).toRule(RuleType.PUSHDOWN_PROJECT_THROUGH_SEMI_JOIN_RIGHT)
}).toRule(RuleType.PUSH_DOWN_PROJECT_THROUGH_SEMI_JOIN_RIGHT)
);
}

View File

@ -45,7 +45,7 @@ import java.util.stream.Collectors;
* UnionAll output(c1, c2 as c2t, c3)
* </pre>
*/
public class PushdownAliasIntoUnionAll extends OneRewriteRuleFactory {
public class PushDownAliasIntoUnionAll extends OneRewriteRuleFactory {
@Override
public Rule build() {
return logicalProject(logicalUnion())
@ -80,6 +80,6 @@ public class PushdownAliasIntoUnionAll extends OneRewriteRuleFactory {
List<NamedExpression> newProjects = project.getProjects().stream().map(NamedExpression::toSlot)
.collect(Collectors.toList());
return PlanUtils.projectOrSelf(newProjects, union.withNewOutputs(newOutput));
}).toRule(RuleType.PUSHDOWN_ALIAS_INTO_UNION_ALL);
}).toRule(RuleType.PUSH_DOWN_ALIAS_INTO_UNION_ALL);
}
}

View File

@ -42,7 +42,7 @@ import java.util.stream.Stream;
/**
* Pushdown Alias (inside must be Slot) through Join.
*/
public class PushdownAliasThroughJoin extends OneRewriteRuleFactory {
public class PushDownAliasThroughJoin extends OneRewriteRuleFactory {
@Override
public Rule build() {
return logicalProject(logicalJoin())
@ -99,7 +99,7 @@ public class PushdownAliasThroughJoin extends OneRewriteRuleFactory {
Plan newJoin = join.withConjunctsChildren(newHash, newOther, left, right);
return project.withProjectsAndChild(newProjects, newJoin);
}).toRule(RuleType.PUSHDOWN_ALIAS_THROUGH_JOIN);
}).toRule(RuleType.PUSH_DOWN_ALIAS_THROUGH_JOIN);
}
private List<Expression> replaceJoinConjuncts(List<Expression> joinConjuncts, Map<ExprId, Slot> replaceMaps) {

View File

@ -67,7 +67,7 @@ import java.util.Set;
* </pre>
* Notice: rule can't optimize condition that groupby is empty when Count(*) exists.
*/
public class PushdownCountThroughJoin implements RewriteRuleFactory {
public class PushDownCountThroughJoin implements RewriteRuleFactory {
@Override
public List<Rule> buildRules() {
return ImmutableList.of(
@ -84,13 +84,13 @@ public class PushdownCountThroughJoin implements RewriteRuleFactory {
.thenApply(ctx -> {
Set<Integer> enableNereidsRules = ctx.cascadesContext.getConnectContext()
.getSessionVariable().getEnableNereidsRules();
if (!enableNereidsRules.contains(RuleType.PUSHDOWN_COUNT_THROUGH_JOIN.type())) {
if (!enableNereidsRules.contains(RuleType.PUSH_DOWN_COUNT_THROUGH_JOIN.type())) {
return null;
}
LogicalAggregate<LogicalJoin<Plan, Plan>> agg = ctx.root;
return pushCount(agg, agg.child(), ImmutableList.of());
})
.toRule(RuleType.PUSHDOWN_COUNT_THROUGH_JOIN),
.toRule(RuleType.PUSH_DOWN_COUNT_THROUGH_JOIN),
logicalAggregate(logicalProject(innerLogicalJoin()))
.when(agg -> agg.child().isAllSlots())
.when(agg -> agg.child().child().getOtherJoinConjuncts().isEmpty())
@ -105,13 +105,13 @@ public class PushdownCountThroughJoin implements RewriteRuleFactory {
.thenApply(ctx -> {
Set<Integer> enableNereidsRules = ctx.cascadesContext.getConnectContext()
.getSessionVariable().getEnableNereidsRules();
if (!enableNereidsRules.contains(RuleType.PUSHDOWN_COUNT_THROUGH_JOIN.type())) {
if (!enableNereidsRules.contains(RuleType.PUSH_DOWN_COUNT_THROUGH_JOIN.type())) {
return null;
}
LogicalAggregate<LogicalProject<LogicalJoin<Plan, Plan>>> agg = ctx.root;
return pushCount(agg, agg.child().child(), agg.child().getProjects());
})
.toRule(RuleType.PUSHDOWN_COUNT_THROUGH_JOIN)
.toRule(RuleType.PUSH_DOWN_COUNT_THROUGH_JOIN)
);
}

View File

@ -36,12 +36,12 @@ import java.util.function.Function;
/**
* PushdownDistinctThroughJoin
*/
public class PushdownDistinctThroughJoin extends DefaultPlanRewriter<JobContext> implements CustomRewriter {
public class PushDownDistinctThroughJoin extends DefaultPlanRewriter<JobContext> implements CustomRewriter {
@Override
public Plan rewriteRoot(Plan plan, JobContext context) {
Set<Integer> enableNereidsRules = context.getCascadesContext().getConnectContext()
.getSessionVariable().getEnableNereidsRules();
if (!enableNereidsRules.contains(RuleType.PUSHDOWN_DISTINCT_THROUGH_JOIN.type())) {
if (!enableNereidsRules.contains(RuleType.PUSH_DOWN_DISTINCT_THROUGH_JOIN.type())) {
return null;
}
return plan.accept(this, context);

View File

@ -43,7 +43,7 @@ import java.util.Set;
/**
* push down expression which is not slot reference
*/
public class PushdownExpressionsInHashCondition extends OneRewriteRuleFactory {
public class PushDownExpressionsInHashCondition extends OneRewriteRuleFactory {
/*
* rewrite example:
* join(t1.a + 1 = t2.b + 2) join(c = d)
@ -64,8 +64,8 @@ public class PushdownExpressionsInHashCondition extends OneRewriteRuleFactory {
return logicalJoin()
.when(join -> join.getHashJoinConjuncts().stream().anyMatch(equalTo ->
equalTo.children().stream().anyMatch(e -> !(e instanceof Slot))))
.then(PushdownExpressionsInHashCondition::pushDownHashExpression)
.toRule(RuleType.PUSHDOWN_EXPRESSIONS_IN_HASH_CONDITIONS);
.then(PushDownExpressionsInHashCondition::pushDownHashExpression)
.toRule(RuleType.PUSH_DOWN_EXPRESSIONS_IN_HASH_CONDITIONS);
}
/**

View File

@ -52,7 +52,7 @@ import java.util.Set;
* but 'b>0' could not push down, because 'b' is not in group by keys.
*/
public class PushdownFilterThroughAggregation extends OneRewriteRuleFactory {
public class PushDownFilterThroughAggregation extends OneRewriteRuleFactory {
@Override
public Rule build() {
@ -77,7 +77,7 @@ public class PushdownFilterThroughAggregation extends OneRewriteRuleFactory {
Plan bottomFilter = new LogicalFilter<>(pushDownPredicates, aggregate.child(0));
aggregate = aggregate.withChildren(ImmutableList.of(bottomFilter));
return PlanUtils.filterOrSelf(filterPredicates, aggregate);
}).toRule(RuleType.PUSHDOWN_PREDICATE_THROUGH_AGGREGATION);
}).toRule(RuleType.PUSH_DOWN_PREDICATE_THROUGH_AGGREGATION);
}
/**

View File

@ -38,8 +38,8 @@ import java.util.Set;
/**
* Push the predicate in the LogicalFilter to the join children.
*/
public class PushdownFilterThroughJoin extends OneRewriteRuleFactory {
public static final PushdownFilterThroughJoin INSTANCE = new PushdownFilterThroughJoin();
public class PushDownFilterThroughJoin extends OneRewriteRuleFactory {
public static final PushDownFilterThroughJoin INSTANCE = new PushDownFilterThroughJoin();
private static final ImmutableList<JoinType> COULD_PUSH_THROUGH_LEFT = ImmutableList.of(
JoinType.INNER_JOIN,
@ -141,7 +141,7 @@ public class PushdownFilterThroughJoin extends OneRewriteRuleFactory {
join.getMarkJoinSlotReference(),
PlanUtils.filterOrSelf(leftPredicates, join.left()),
PlanUtils.filterOrSelf(rightPredicates, join.right())));
}).toRule(RuleType.PUSHDOWN_FILTER_THROUGH_JOIN);
}).toRule(RuleType.PUSH_DOWN_FILTER_THROUGH_JOIN);
}
private boolean convertJoinCondition(Expression predicate, Set<Slot> leftOutputs, Set<Slot> rightOutputs,

View File

@ -51,7 +51,7 @@ import java.util.Set;
* any_node
*/
public class PushdownFilterThroughPartitionTopN extends OneRewriteRuleFactory {
public class PushDownFilterThroughPartitionTopN extends OneRewriteRuleFactory {
@Override
public Rule build() {
@ -91,7 +91,7 @@ public class PushdownFilterThroughPartitionTopN extends OneRewriteRuleFactory {
} else {
return filter.withConjunctsAndChild(upperConjuncts, partitionTopN);
}
}).toRule(RuleType.PUSHDOWN_FILTER_THROUGH_PARTITION_TOPN);
}).toRule(RuleType.PUSH_DOWN_FILTER_THROUGH_PARTITION_TOPN);
}
}

View File

@ -37,15 +37,15 @@ import java.util.List;
* output:
* project(c+d as a, e as b) -> filter(c+d>2, e=0).
*/
public class PushdownFilterThroughProject implements RewriteRuleFactory {
public class PushDownFilterThroughProject implements RewriteRuleFactory {
@Override
public List<Rule> buildRules() {
return ImmutableList.of(
logicalFilter(logicalProject())
.whenNot(filter -> filter.child().getProjects().stream().anyMatch(
expr -> expr.anyMatch(WindowExpression.class::isInstance)))
.then(PushdownFilterThroughProject::pushdownFilterThroughProject)
.toRule(RuleType.PUSHDOWN_FILTER_THROUGH_PROJECT),
.then(PushDownFilterThroughProject::pushdownFilterThroughProject)
.toRule(RuleType.PUSH_DOWN_FILTER_THROUGH_PROJECT),
// filter(project(limit)) will change to filter(limit(project)) by PushdownProjectThroughLimit,
// then we should change filter(limit(project)) to project(filter(limit))
logicalFilter(logicalLimit(logicalProject()))
@ -60,7 +60,7 @@ public class PushdownFilterThroughProject implements RewriteRuleFactory {
ExpressionUtils.replace(filter.getConjuncts(),
project.getAliasToProducer()),
limit.withChildren(project.child())));
}).toRule(RuleType.PUSHDOWN_FILTER_THROUGH_PROJECT_UNDER_LIMIT)
}).toRule(RuleType.PUSH_DOWN_FILTER_THROUGH_PROJECT_UNDER_LIMIT)
);
}

View File

@ -57,7 +57,7 @@ import java.util.Set;
* but 'b>0' could not push down, because 'b' is not in group by keys.
*/
public class PushdownFilterThroughRepeat extends OneRewriteRuleFactory {
public class PushDownFilterThroughRepeat extends OneRewriteRuleFactory {
@Override
public Rule build() {
@ -79,7 +79,7 @@ public class PushdownFilterThroughRepeat extends OneRewriteRuleFactory {
}
}
return pushDownPredicate(filter, pushedPredicates, notPushedPredicates);
}).toRule(RuleType.PUSHDOWN_PREDICATE_THROUGH_REPEAT);
}).toRule(RuleType.PUSH_DOWN_PREDICATE_THROUGH_REPEAT);
}
private Plan pushDownPredicate(LogicalFilter<LogicalRepeat<Plan>> filter, Set<Expression> pushedPredicates,

View File

@ -37,7 +37,7 @@ import java.util.Set;
/**
* Convert the expression in the filter into the output column corresponding to the child node and push it down.
*/
public class PushdownFilterThroughSetOperation extends OneRewriteRuleFactory {
public class PushDownFilterThroughSetOperation extends OneRewriteRuleFactory {
@Override
public Rule build() {
@ -57,6 +57,6 @@ public class PushdownFilterThroughSetOperation extends OneRewriteRuleFactory {
}
return setOperation.withChildren(newChildren);
}).toRule(RuleType.PUSHDOWN_FILTER_THROUGH_SET_OPERATION);
}).toRule(RuleType.PUSH_DOWN_FILTER_THROUGH_SET_OPERATION);
}
}

View File

@ -36,7 +36,7 @@ import java.util.Set;
* The filter can be directly push down to the sort.
* Note when the sort key is equal to Literal, the sort can be eliminated
*/
public class PushdownFilterThroughSort extends OneRewriteRuleFactory {
public class PushDownFilterThroughSort extends OneRewriteRuleFactory {
@Override
public Rule build() {
return logicalFilter(logicalSort()).then(filter -> {
@ -45,7 +45,7 @@ public class PushdownFilterThroughSort extends OneRewriteRuleFactory {
return new LogicalFilter<>(filter.getConjuncts(), sort.child());
}
return sort.withChildren(new LogicalFilter<>(filter.getConjuncts(), sort.child()));
}).toRule(RuleType.PUSHDOWN_FILTER_THROUGH_SORT);
}).toRule(RuleType.PUSH_DOWN_FILTER_THROUGH_SORT);
}
boolean checkSlotsConstant(Set<Slot> slots, LogicalFilter<? extends Plan> filter) {

View File

@ -49,7 +49,7 @@ import java.util.Set;
* any_node
*/
public class PushdownFilterThroughWindow extends OneRewriteRuleFactory {
public class PushDownFilterThroughWindow extends OneRewriteRuleFactory {
@Override
public Rule build() {
@ -92,7 +92,7 @@ public class PushdownFilterThroughWindow extends OneRewriteRuleFactory {
.withConjuncts(upperConjuncts).withChildren(window);
return upperFilter;
}
}).toRule(RuleType.PUSHDOWN_FILTER_THROUGH_WINDOW);
}).toRule(RuleType.PUSH_DOWN_FILTER_THROUGH_WINDOW);
}
}

View File

@ -37,7 +37,7 @@ import java.util.Set;
/**
* Push the other join conditions in LogicalJoin to children.
*/
public class PushdownJoinOtherCondition extends OneRewriteRuleFactory {
public class PushDownJoinOtherCondition extends OneRewriteRuleFactory {
private static final ImmutableList<JoinType> PUSH_DOWN_LEFT_VALID_TYPE = ImmutableList.of(
JoinType.INNER_JOIN,
JoinType.LEFT_SEMI_JOIN,
@ -91,7 +91,7 @@ public class PushdownJoinOtherCondition extends OneRewriteRuleFactory {
return new LogicalJoin<>(join.getJoinType(), join.getHashJoinConjuncts(),
remainingOther, join.getHint(), join.getMarkJoinSlotReference(), left, right);
}).toRule(RuleType.PUSHDOWN_JOIN_OTHER_CONDITION);
}).toRule(RuleType.PUSH_DOWN_JOIN_OTHER_CONDITION);
}
private boolean allCoveredBy(Expression predicate, Set<Slot> inputSlotSet) {

View File

@ -39,7 +39,7 @@ import java.util.Optional;
* Limit can't be push down if it has a valid offset info.
* splitLimit run before this rule, so the limit match the patterns is local limit
*/
public class PushdownLimit implements RewriteRuleFactory {
public class PushDownLimit implements RewriteRuleFactory {
@Override
public List<Rule> buildRules() {

View File

@ -34,7 +34,7 @@ import java.util.stream.Collectors;
/**
* Same with PushdownLimit
*/
public class PushdownLimitDistinctThroughJoin implements RewriteRuleFactory {
public class PushDownLimitDistinctThroughJoin implements RewriteRuleFactory {
@Override
public List<Rule> buildRules() {

View File

@ -61,7 +61,7 @@ import java.util.Set;
* aggregate: Min/Max(x) as min1
* </pre>
*/
public class PushdownMinMaxThroughJoin implements RewriteRuleFactory {
public class PushDownMinMaxThroughJoin implements RewriteRuleFactory {
@Override
public List<Rule> buildRules() {
return ImmutableList.of(
@ -77,13 +77,13 @@ public class PushdownMinMaxThroughJoin implements RewriteRuleFactory {
.thenApply(ctx -> {
Set<Integer> enableNereidsRules = ctx.cascadesContext.getConnectContext()
.getSessionVariable().getEnableNereidsRules();
if (!enableNereidsRules.contains(RuleType.PUSHDOWN_MIN_MAX_THROUGH_JOIN.type())) {
if (!enableNereidsRules.contains(RuleType.PUSH_DOWN_MIN_MAX_THROUGH_JOIN.type())) {
return null;
}
LogicalAggregate<LogicalJoin<Plan, Plan>> agg = ctx.root;
return pushMinMax(agg, agg.child(), ImmutableList.of());
})
.toRule(RuleType.PUSHDOWN_MIN_MAX_THROUGH_JOIN),
.toRule(RuleType.PUSH_DOWN_MIN_MAX_THROUGH_JOIN),
logicalAggregate(logicalProject(innerLogicalJoin()))
.when(agg -> agg.child().isAllSlots())
.when(agg -> agg.child().child().getOtherJoinConjuncts().isEmpty())
@ -98,13 +98,13 @@ public class PushdownMinMaxThroughJoin implements RewriteRuleFactory {
.thenApply(ctx -> {
Set<Integer> enableNereidsRules = ctx.cascadesContext.getConnectContext()
.getSessionVariable().getEnableNereidsRules();
if (!enableNereidsRules.contains(RuleType.PUSHDOWN_MIN_MAX_THROUGH_JOIN.type())) {
if (!enableNereidsRules.contains(RuleType.PUSH_DOWN_MIN_MAX_THROUGH_JOIN.type())) {
return null;
}
LogicalAggregate<LogicalProject<LogicalJoin<Plan, Plan>>> agg = ctx.root;
return pushMinMax(agg, agg.child().child(), agg.child().getProjects());
})
.toRule(RuleType.PUSHDOWN_MIN_MAX_THROUGH_JOIN)
.toRule(RuleType.PUSH_DOWN_MIN_MAX_THROUGH_JOIN)
);
}

View File

@ -45,7 +45,7 @@ import org.apache.doris.nereids.trees.plans.logical.LogicalProject;
* plan node
* </pre>
*/
public class PushdownProjectThroughLimit extends OneRewriteRuleFactory {
public class PushDownProjectThroughLimit extends OneRewriteRuleFactory {
@Override
public Rule build() {
@ -53,6 +53,6 @@ public class PushdownProjectThroughLimit extends OneRewriteRuleFactory {
LogicalProject<LogicalLimit<Plan>> logicalProject = ctx.root;
LogicalLimit<Plan> logicalLimit = logicalProject.child();
return logicalLimit.withChildren(logicalProject.withChildren(logicalLimit.child()));
}).toRule(RuleType.PUSHDOWN_PROJECT_THROUGH_LIMIT);
}).toRule(RuleType.PUSH_DOWN_PROJECT_THROUGH_LIMIT);
}
}

View File

@ -61,7 +61,7 @@ import java.util.Set;
* aggregate: Sum(x) as min1
* </pre>
*/
public class PushdownSumThroughJoin implements RewriteRuleFactory {
public class PushDownSumThroughJoin implements RewriteRuleFactory {
@Override
public List<Rule> buildRules() {
return ImmutableList.of(
@ -76,13 +76,13 @@ public class PushdownSumThroughJoin implements RewriteRuleFactory {
.thenApply(ctx -> {
Set<Integer> enableNereidsRules = ctx.cascadesContext.getConnectContext()
.getSessionVariable().getEnableNereidsRules();
if (!enableNereidsRules.contains(RuleType.PUSHDOWN_SUM_THROUGH_JOIN.type())) {
if (!enableNereidsRules.contains(RuleType.PUSH_DOWN_SUM_THROUGH_JOIN.type())) {
return null;
}
LogicalAggregate<LogicalJoin<Plan, Plan>> agg = ctx.root;
return pushSum(agg, agg.child(), ImmutableList.of());
})
.toRule(RuleType.PUSHDOWN_SUM_THROUGH_JOIN),
.toRule(RuleType.PUSH_DOWN_SUM_THROUGH_JOIN),
logicalAggregate(logicalProject(innerLogicalJoin()))
.when(agg -> agg.child().isAllSlots())
.when(agg -> agg.child().child().getOtherJoinConjuncts().isEmpty())
@ -95,13 +95,13 @@ public class PushdownSumThroughJoin implements RewriteRuleFactory {
.thenApply(ctx -> {
Set<Integer> enableNereidsRules = ctx.cascadesContext.getConnectContext()
.getSessionVariable().getEnableNereidsRules();
if (!enableNereidsRules.contains(RuleType.PUSHDOWN_SUM_THROUGH_JOIN.type())) {
if (!enableNereidsRules.contains(RuleType.PUSH_DOWN_SUM_THROUGH_JOIN.type())) {
return null;
}
LogicalAggregate<LogicalProject<LogicalJoin<Plan, Plan>>> agg = ctx.root;
return pushSum(agg, agg.child().child(), agg.child().getProjects());
})
.toRule(RuleType.PUSHDOWN_SUM_THROUGH_JOIN)
.toRule(RuleType.PUSH_DOWN_SUM_THROUGH_JOIN)
);
}

View File

@ -35,7 +35,7 @@ import java.util.stream.Collectors;
/**
* Push down TopN through Outer Join into left child .....
*/
public class PushdownTopNThroughJoin implements RewriteRuleFactory {
public class PushDownTopNThroughJoin implements RewriteRuleFactory {
@Override
public List<Rule> buildRules() {

View File

@ -38,7 +38,7 @@ import java.util.Optional;
/**
* PushdownTopNThroughWindow push down the TopN through the Window and generate the PartitionTopN.
*/
public class PushdownTopNThroughWindow implements RewriteRuleFactory {
public class PushDownTopNThroughWindow implements RewriteRuleFactory {
@Override
public List<Rule> buildRules() {
return ImmutableList.of(

View File

@ -50,7 +50,7 @@ public class TransposeSemiJoinAgg extends OneRewriteRuleFactory {
*/
public static boolean canTranspose(LogicalAggregate<? extends Plan> aggregate,
LogicalJoin<? extends Plan, ? extends Plan> join) {
Set<Slot> canPushDownSlots = PushdownFilterThroughAggregation.getCanPushDownSlots(aggregate);
Set<Slot> canPushDownSlots = PushDownFilterThroughAggregation.getCanPushDownSlots(aggregate);
Set<Slot> leftConditionSlot = join.getLeftConditionSlot();
return canPushDownSlots.containsAll(leftConditionSlot);
}