Skip to content

Commit

Permalink
[enhancement](Nereids): remove LAsscom in Bushy Tree RuleSet by jackw…
Browse files Browse the repository at this point in the history
…ener
  • Loading branch information
kaka11chen committed Oct 25, 2023
1 parent 4220806 commit 1101f5f
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,6 @@ public class RuleSet {

public static final List<Rule> BUSHY_TREE_JOIN_REORDER = planRuleFactories()
.add(JoinCommute.BUSHY)
.add(InnerJoinLAsscom.INSTANCE)
.add(InnerJoinLAsscomProject.INSTANCE)
.add(InnerJoinLeftAssociate.INSTANCE)
.add(InnerJoinLeftAssociateProject.INSTANCE)
.add(InnerJoinRightAssociate.INSTANCE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,10 @@ public enum RuleType {
LOGICAL_OUTER_JOIN_LASSCOM_PROJECT(RuleTypeClass.EXPLORATION),
LOGICAL_OUTER_JOIN_ASSOC(RuleTypeClass.EXPLORATION),
LOGICAL_OUTER_JOIN_ASSOC_PROJECT(RuleTypeClass.EXPLORATION),
LOGICAL_JOIN_LOGICAL_SEMI_JOIN_TRANSPOSE(RuleTypeClass.EXPLORATION),
LOGICAL_JOIN_LOGICAL_SEMI_JOIN_TRANSPOSE_PROJECT(RuleTypeClass.EXPLORATION),
LOGICAL_JOIN_LOGICAL_SEMI_JOIN_TRANSPOSE_LEFT(RuleTypeClass.EXPLORATION),
LOGICAL_JOIN_LOGICAL_SEMI_JOIN_TRANSPOSE_RIGHT(RuleTypeClass.EXPLORATION),
LOGICAL_JOIN_LOGICAL_SEMI_JOIN_TRANSPOSE_LEFT_PROJECT(RuleTypeClass.EXPLORATION),
LOGICAL_JOIN_LOGICAL_SEMI_JOIN_TRANSPOSE_RIGHT_PROJECT(RuleTypeClass.EXPLORATION),
LOGICAL_SEMI_JOIN_SEMI_JOIN_TRANSPOSE(RuleTypeClass.EXPLORATION),
LOGICAL_SEMI_JOIN_SEMI_JOIN_TRANSPOSE_PROJECT(RuleTypeClass.EXPLORATION),
LOGICAL_JOIN_EXCHANGE(RuleTypeClass.EXPLORATION),
Expand All @@ -285,8 +287,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),
PUSH_DOWN_PROJECT_THROUGH_SEMI_JOIN(RuleTypeClass.EXPLORATION),
PUSH_DOWN_PROJECT_THROUGH_INNER_OUTER_JOIN(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),
EAGER_COUNT(RuleTypeClass.EXPLORATION),
EAGER_GROUP_BY(RuleTypeClass.EXPLORATION),
EAGER_GROUP_BY_COUNT(RuleTypeClass.EXPLORATION),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,6 @@ public Rule build() {
InnerJoinLeftAssociate.setNewTopJoinReorder(newTopJoin, topJoin);

return CBOUtils.projectOrSelf(ImmutableList.copyOf(topJoin.getOutput()), newTopJoin);
}).toRule(RuleType.LOGICAL_INNER_JOIN_LEFT_ASSOCIATIVE);
}).toRule(RuleType.LOGICAL_INNER_JOIN_LEFT_ASSOCIATIVE_PROJECT);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public Rule build() {
setNewTopJoinReorder(newTopJoin, topJoin);

return CBOUtils.projectOrSelf(ImmutableList.copyOf(topJoin.getOutput()), newTopJoin);
}).toRule(RuleType.LOGICAL_INNER_JOIN_RIGHT_ASSOCIATIVE);
}).toRule(RuleType.LOGICAL_INNER_JOIN_RIGHT_ASSOCIATIVE_PROJECT);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public Rule build() {
JoinExchange.setNewTopJoinReorder(newTopJoin, topJoin);

return CBOUtils.projectOrSelf(ImmutableList.copyOf(topJoin.getOutput()), newTopJoin);
}).toRule(RuleType.LOGICAL_JOIN_EXCHANGE);
}).toRule(RuleType.LOGICAL_JOIN_EXCHANGE_BOTH_PROJECT);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public Rule build() {
JoinExchange.setNewTopJoinReorder(newTopJoin, topJoin);

return CBOUtils.projectOrSelf(ImmutableList.copyOf(topJoin.getOutput()), newTopJoin);
}).toRule(RuleType.LOGICAL_JOIN_EXCHANGE);
}).toRule(RuleType.LOGICAL_JOIN_EXCHANGE_LEFT_PROJECT);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public Rule build() {
JoinExchange.setNewTopJoinReorder(newTopJoin, topJoin);

return CBOUtils.projectOrSelf(ImmutableList.copyOf(topJoin.getOutput()), newTopJoin);
}).toRule(RuleType.LOGICAL_JOIN_EXCHANGE);
}).toRule(RuleType.LOGICAL_JOIN_EXCHANGE_RIGHT_PROJECT);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public List<Rule> buildRules() {

Plan newBottomJoin = topJoin.withChildrenNoContext(a, c);
return bottomJoin.withChildrenNoContext(newBottomJoin, b);
}).toRule(RuleType.LOGICAL_JOIN_LOGICAL_SEMI_JOIN_TRANSPOSE),
}).toRule(RuleType.LOGICAL_JOIN_LOGICAL_SEMI_JOIN_TRANSPOSE_LEFT),

logicalJoin(group(), logicalJoin())
.when(topJoin -> (topJoin.right().getJoinType().isLeftSemiOrAntiJoin()
Expand All @@ -71,7 +71,7 @@ public List<Rule> buildRules() {

Plan newBottomJoin = topJoin.withChildrenNoContext(a, b);
return bottomJoin.withChildrenNoContext(newBottomJoin, c);
}).toRule(RuleType.LOGICAL_JOIN_LOGICAL_SEMI_JOIN_TRANSPOSE)
}).toRule(RuleType.LOGICAL_JOIN_LOGICAL_SEMI_JOIN_TRANSPOSE_RIGHT)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public List<Rule> buildRules() {
Plan newTopJoin = bottomJoin.withChildrenNoContext(newBottomJoin, b);
return CBOUtils.projectOrSelf(ImmutableList.copyOf(topJoin.getOutput()),
newTopJoin);
}).toRule(RuleType.LOGICAL_JOIN_LOGICAL_SEMI_JOIN_TRANSPOSE_PROJECT),
}).toRule(RuleType.LOGICAL_JOIN_LOGICAL_SEMI_JOIN_TRANSPOSE_LEFT_PROJECT),

logicalJoin(group(), logicalProject(logicalJoin()))
.when(topJoin -> (topJoin.right().child().getJoinType().isLeftSemiOrAntiJoin()
Expand All @@ -80,7 +80,7 @@ public List<Rule> buildRules() {
Plan newTopJoin = bottomJoin.withChildrenNoContext(newBottomJoin, c);
return CBOUtils.projectOrSelf(ImmutableList.copyOf(topJoin.getOutput()),
newTopJoin);
}).toRule(RuleType.LOGICAL_JOIN_LOGICAL_SEMI_JOIN_TRANSPOSE_PROJECT)
}).toRule(RuleType.LOGICAL_JOIN_LOGICAL_SEMI_JOIN_TRANSPOSE_RIGHT_PROJECT)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public class PushdownProjectThroughInnerOuterJoin implements ExplorationRuleFact
@Override
public List<Rule> buildRules() {
return ImmutableList.of(
logicalJoin(logicalProject(logicalJoin()), group())
logicalJoin(logicalProject(logicalJoin().whenNot(LogicalJoin::isMarkJoin)), group())
.when(j -> j.left().child().getJoinType().isOuterJoin()
|| j.left().child().getJoinType().isInnerJoin())
// Just pushdown project with non-column expr like (t.id + 1)
Expand All @@ -69,7 +69,7 @@ public List<Rule> buildRules() {
return null;
}
return topJoin.withChildren(newLeft, topJoin.right());
}).toRule(RuleType.PUSH_DOWN_PROJECT_THROUGH_INNER_OUTER_JOIN),
}).toRule(RuleType.PUSHDOWN_PROJECT_THROUGH_INNER_OUTER_JOIN_LEFT),
logicalJoin(group(), logicalProject(logicalJoin()))
.when(j -> j.right().child().getJoinType().isOuterJoin()
|| j.right().child().getJoinType().isInnerJoin())
Expand All @@ -83,7 +83,7 @@ public List<Rule> buildRules() {
return null;
}
return topJoin.withChildren(topJoin.left(), newRight);
}).toRule(RuleType.PUSH_DOWN_PROJECT_THROUGH_INNER_OUTER_JOIN)
}).toRule(RuleType.PUSHDOWN_PROJECT_THROUGH_INNER_OUTER_JOIN_RIGHT)
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public class PushdownProjectThroughSemiJoin implements ExplorationRuleFactory {
@Override
public List<Rule> buildRules() {
return ImmutableList.of(
logicalJoin(logicalProject(logicalJoin()), group())
logicalJoin(logicalProject(logicalJoin().whenNot(LogicalJoin::isMarkJoin)), group())
.when(j -> j.left().child().getJoinType().isLeftSemiOrAntiJoin())
// Just pushdown project with non-column expr like (t.id + 1)
.whenNot(j -> j.left().isAllSlots())
Expand All @@ -63,7 +63,7 @@ public List<Rule> buildRules() {
LogicalProject<LogicalJoin<GroupPlan, GroupPlan>> project = topJoin.left();
Plan newLeft = pushdownProject(project);
return topJoin.withChildren(newLeft, topJoin.right());
}).toRule(RuleType.PUSH_DOWN_PROJECT_THROUGH_SEMI_JOIN),
}).toRule(RuleType.PUSHDOWN_PROJECT_THROUGH_SEMI_JOIN_LEFT),

logicalJoin(group(), logicalProject(logicalJoin()))
.when(j -> j.right().child().getJoinType().isLeftSemiOrAntiJoin())
Expand All @@ -74,7 +74,7 @@ public List<Rule> buildRules() {
LogicalProject<LogicalJoin<GroupPlan, GroupPlan>> project = topJoin.right();
Plan newRight = pushdownProject(project);
return topJoin.withChildren(topJoin.left(), newRight);
}).toRule(RuleType.PUSH_DOWN_PROJECT_THROUGH_SEMI_JOIN)
}).toRule(RuleType.PUSHDOWN_PROJECT_THROUGH_SEMI_JOIN_RIGHT)
);
}

Expand Down

0 comments on commit 1101f5f

Please sign in to comment.