[enhancement](Nereids)ban groupPlan() pattern to avoid misuse (#12250)

`groupPlan()` pattern means to find a `GroupPlan` in memo. Since we have no `GroupPlan` in memo, it is always return nothing.
When we want write a pattern to match any GROUP, we should use `group()`. But pattern `groupPlan` is very confusing, and easy misuse.
So, this PR ban `groupPlan()` pattern ti avoid misuse.
This commit is contained in:
morrySnow
2022-09-01 14:37:48 +08:00
committed by GitHub
parent 3bcab8bbef
commit 068e60145e
3 changed files with 3 additions and 2 deletions

View File

@ -76,6 +76,7 @@ public class PatternGeneratorAnalyzer {
private String doGenerate() {
Map<ClassDeclaration, Set<String>> planClassMap = parentClassMap.entrySet().stream()
.filter(kv -> kv.getValue().contains("org.apache.doris.nereids.trees.plans.Plan"))
.filter(kv -> !kv.getKey().name.equals("GroupPlan"))
.filter(kv -> !Modifier.isAbstract(kv.getKey().modifiers.mod)
&& kv.getKey() instanceof ClassDeclaration)
.collect(Collectors.toMap(kv -> (ClassDeclaration) kv.getKey(), kv -> kv.getValue()));

View File

@ -38,7 +38,7 @@ public class JoinLAsscom extends OneExplorationRuleFactory {
*/
@Override
public Rule build() {
return logicalJoin(logicalJoin(), groupPlan())
return logicalJoin(logicalJoin(), group())
.when(JoinLAsscomHelper::check)
.when(join -> join.getJoinType().isInnerJoin() || join.getJoinType().isLeftOuterJoin()
&& (join.left().getJoinType().isInnerJoin() || join.left().getJoinType().isLeftOuterJoin()))

View File

@ -40,7 +40,7 @@ public class JoinLAsscomProject extends OneExplorationRuleFactory {
*/
@Override
public Rule build() {
return logicalJoin(logicalProject(logicalJoin()), groupPlan())
return logicalJoin(logicalProject(logicalJoin()), group())
.when(JoinLAsscomHelper::check)
.when(join -> join.getJoinType().isInnerJoin() || join.getJoinType().isLeftOuterJoin()
&& (join.left().child().getJoinType().isInnerJoin() || join.left().child().getJoinType()