This is an automated email from the ASF dual-hosted git repository.
huajianlan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 76028265e8 [refactor](Nereids): merge rewrite job (#11950)
76028265e8 is described below
commit 76028265e861e19089a7f5809857bfeab5fd9392
Author: jakevin <[email protected]>
AuthorDate: Tue Aug 23 20:06:34 2022 +0800
[refactor](Nereids): merge rewrite job (#11950)
merge rewrite job
---
.../org/apache/doris/nereids/NereidsPlanner.java | 12 ++-----
.../nereids/jobs/batch/DisassembleRulesJob.java | 36 -------------------
.../nereids/jobs/batch/JoinReorderRulesJob.java | 36 -------------------
.../jobs/batch/MergeConsecutiveProjectJob.java | 41 ----------------------
.../jobs/batch/PredicatePushDownRulesJob.java | 36 -------------------
...lizeExpressionRulesJob.java => RewriteJob.java} | 24 +++++++++----
6 files changed, 19 insertions(+), 166 deletions(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/NereidsPlanner.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/NereidsPlanner.java
index 5be733f91c..5dcfc4f936 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/NereidsPlanner.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/NereidsPlanner.java
@@ -24,12 +24,8 @@ import org.apache.doris.common.UserException;
import org.apache.doris.nereids.glue.LogicalPlanAdapter;
import org.apache.doris.nereids.glue.translator.PhysicalPlanTranslator;
import org.apache.doris.nereids.glue.translator.PlanTranslatorContext;
-import org.apache.doris.nereids.jobs.batch.DisassembleRulesJob;
-import org.apache.doris.nereids.jobs.batch.JoinReorderRulesJob;
-import org.apache.doris.nereids.jobs.batch.MergeConsecutiveProjectJob;
-import org.apache.doris.nereids.jobs.batch.NormalizeExpressionRulesJob;
import org.apache.doris.nereids.jobs.batch.OptimizeRulesJob;
-import org.apache.doris.nereids.jobs.batch.PredicatePushDownRulesJob;
+import org.apache.doris.nereids.jobs.batch.RewriteJob;
import org.apache.doris.nereids.jobs.cascades.DeriveStatsJob;
import org.apache.doris.nereids.memo.Group;
import org.apache.doris.nereids.memo.GroupExpression;
@@ -144,11 +140,7 @@ public class NereidsPlanner extends Planner {
* Logical plan rewrite based on a series of heuristic rules.
*/
private void rewrite() {
- new MergeConsecutiveProjectJob(cascadesContext).execute();
- new NormalizeExpressionRulesJob(cascadesContext).execute();
- new JoinReorderRulesJob(cascadesContext).execute();
- new PredicatePushDownRulesJob(cascadesContext).execute();
- new DisassembleRulesJob(cascadesContext).execute();
+ new RewriteJob(cascadesContext).execute();
}
private void deriveStats() {
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/batch/DisassembleRulesJob.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/batch/DisassembleRulesJob.java
deleted file mode 100644
index 81c7257f33..0000000000
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/batch/DisassembleRulesJob.java
+++ /dev/null
@@ -1,36 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-package org.apache.doris.nereids.jobs.batch;
-
-import org.apache.doris.nereids.CascadesContext;
-import org.apache.doris.nereids.rules.rewrite.AggregateDisassemble;
-
-import com.google.common.collect.ImmutableList;
-
-/**
- * Execute the disassemble rules.
- */
-public class DisassembleRulesJob extends BatchRulesJob {
- public DisassembleRulesJob(CascadesContext cascadesContext) {
- super(cascadesContext);
- rulesJob.addAll(ImmutableList.of(
- topDownBatch(ImmutableList.of(
- new AggregateDisassemble())
- )));
- }
-}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/batch/JoinReorderRulesJob.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/batch/JoinReorderRulesJob.java
deleted file mode 100644
index 0654d08499..0000000000
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/batch/JoinReorderRulesJob.java
+++ /dev/null
@@ -1,36 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-package org.apache.doris.nereids.jobs.batch;
-
-import org.apache.doris.nereids.CascadesContext;
-import org.apache.doris.nereids.rules.rewrite.logical.ReorderJoin;
-
-import com.google.common.collect.ImmutableList;
-
-/**
- * JoinReorderRulesJob
- */
-public class JoinReorderRulesJob extends BatchRulesJob {
-
- public JoinReorderRulesJob(CascadesContext cascadesContext) {
- super(cascadesContext);
- rulesJob.addAll(ImmutableList.of(
- topDownBatch(ImmutableList.of(new ReorderJoin()))
- ));
- }
-}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/batch/MergeConsecutiveProjectJob.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/batch/MergeConsecutiveProjectJob.java
deleted file mode 100644
index a7ccd40124..0000000000
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/batch/MergeConsecutiveProjectJob.java
+++ /dev/null
@@ -1,41 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-package org.apache.doris.nereids.jobs.batch;
-
-import org.apache.doris.nereids.CascadesContext;
-import org.apache.doris.nereids.rules.rewrite.logical.MergeConsecutiveProjects;
-
-import com.google.common.collect.ImmutableList;
-
-/**
- * Merge consecutive project rules.
- */
-public class MergeConsecutiveProjectJob extends BatchRulesJob {
-
- /**
- * Execute the merge consecutive job.
- * @param ctx planner context for execute job
- */
- public MergeConsecutiveProjectJob(CascadesContext ctx) {
- //TODO: eliminate consecutive projects for view
- super(ctx);
- rulesJob.addAll(ImmutableList.of(
- bottomUpBatch(ImmutableList.of(
- new MergeConsecutiveProjects()))));
- }
-}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/batch/PredicatePushDownRulesJob.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/batch/PredicatePushDownRulesJob.java
deleted file mode 100644
index 8886c55c36..0000000000
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/batch/PredicatePushDownRulesJob.java
+++ /dev/null
@@ -1,36 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-package org.apache.doris.nereids.jobs.batch;
-
-import org.apache.doris.nereids.CascadesContext;
-import org.apache.doris.nereids.rules.rewrite.logical.PushPredicateThroughJoin;
-
-import com.google.common.collect.ImmutableList;
-
-/**
- * execute predicate push down job.
- */
-public class PredicatePushDownRulesJob extends BatchRulesJob {
- public PredicatePushDownRulesJob(CascadesContext cascadesContext) {
- super(cascadesContext);
- rulesJob.addAll(ImmutableList.of(
- topDownBatch(ImmutableList.of(
- new PushPredicateThroughJoin())
- )));
- }
-}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/batch/NormalizeExpressionRulesJob.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/batch/RewriteJob.java
similarity index 54%
rename from
fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/batch/NormalizeExpressionRulesJob.java
rename to
fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/batch/RewriteJob.java
index 8c8fd2b8b7..9fa2fe6ec3 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/batch/NormalizeExpressionRulesJob.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/batch/RewriteJob.java
@@ -18,25 +18,35 @@
package org.apache.doris.nereids.jobs.batch;
import org.apache.doris.nereids.CascadesContext;
+import org.apache.doris.nereids.jobs.Job;
import
org.apache.doris.nereids.rules.expression.rewrite.ExpressionNormalization;
+import org.apache.doris.nereids.rules.rewrite.AggregateDisassemble;
+import org.apache.doris.nereids.rules.rewrite.logical.MergeConsecutiveProjects;
+import org.apache.doris.nereids.rules.rewrite.logical.PushPredicateThroughJoin;
+import org.apache.doris.nereids.rules.rewrite.logical.ReorderJoin;
import com.google.common.collect.ImmutableList;
/**
* Apply rules to normalize expressions.
*/
-public class NormalizeExpressionRulesJob extends BatchRulesJob {
+public class RewriteJob extends BatchRulesJob {
/**
* Constructor.
+ *
* @param cascadesContext context for applying rules.
*/
- public NormalizeExpressionRulesJob(CascadesContext cascadesContext) {
+ public RewriteJob(CascadesContext cascadesContext) {
super(cascadesContext);
- rulesJob.addAll(ImmutableList.of(
- topDownBatch(ImmutableList.of(
- new ExpressionNormalization()
- ))
- ));
+ ImmutableList<Job> jobs = new ImmutableList.Builder<Job>()
+ .add(bottomUpBatch(ImmutableList.of(new
MergeConsecutiveProjects())))
+ .add(topDownBatch(ImmutableList.of(new
ExpressionNormalization())))
+ .add(topDownBatch(ImmutableList.of(new ReorderJoin())))
+ .add(topDownBatch(ImmutableList.of(new
PushPredicateThroughJoin())))
+ .add(topDownBatch(ImmutableList.of(new
AggregateDisassemble())))
+ .build().reverse(); // reverse due to jobPool is stack.
+
+ rulesJob.addAll(jobs);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]