This is an automated email from the ASF dual-hosted git repository.
starocean999 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 85a1db4b6c6 [fix](nereids)select base index if select mv fails (#25715)
85a1db4b6c6 is described below
commit 85a1db4b6c60b96192b01f41adaae5556310f6a1
Author: starocean999 <[email protected]>
AuthorDate: Mon Nov 6 17:57:19 2023 +0800
[fix](nereids)select base index if select mv fails (#25715)
---
.../doris/nereids/pattern/PatternDescriptor.java | 19 +++++++++++++++++++
.../mv/SelectMaterializedIndexWithAggregate.java | 20 ++++++++++----------
.../mv/SelectMaterializedIndexWithoutAggregate.java | 10 +++++-----
3 files changed, 34 insertions(+), 15 deletions(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/pattern/PatternDescriptor.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/pattern/PatternDescriptor.java
index c00f1711c5c..90c143be1aa 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/pattern/PatternDescriptor.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/pattern/PatternDescriptor.java
@@ -21,6 +21,8 @@ import org.apache.doris.nereids.rules.RulePromise;
import org.apache.doris.nereids.trees.plans.Plan;
import com.google.common.collect.ImmutableList;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import java.util.List;
import java.util.Objects;
@@ -32,6 +34,7 @@ import java.util.function.Predicate;
* It can support pattern generic type to MatchedAction.
*/
public class PatternDescriptor<INPUT_TYPE extends Plan> {
+ private static final Logger LOG =
LogManager.getLogger(PatternDescriptor.class);
public final Pattern<INPUT_TYPE> pattern;
public final RulePromise defaultPromise;
@@ -63,6 +66,22 @@ public class PatternDescriptor<INPUT_TYPE extends Plan> {
return new PatternMatcher<>(pattern, defaultPromise, matchedAction);
}
+ /**
+ * Same as thenApply, but catch all exception and return null
+ */
+ public <OUTPUT_TYPE extends Plan> PatternMatcher<INPUT_TYPE, OUTPUT_TYPE>
thenApplyNoThrow(
+ MatchedAction<INPUT_TYPE, OUTPUT_TYPE> matchedAction) {
+ MatchedAction<INPUT_TYPE, OUTPUT_TYPE> adaptMatchedAction = ctx -> {
+ try {
+ return matchedAction.apply(ctx);
+ } catch (Exception ex) {
+ LOG.warn("nereids apply rule failed, because {}",
ex.getMessage(), ex);
+ return null;
+ }
+ };
+ return new PatternMatcher<>(pattern, defaultPromise,
adaptMatchedAction);
+ }
+
public <OUTPUT_TYPE extends Plan> PatternMatcher<INPUT_TYPE, OUTPUT_TYPE>
thenMulti(
Function<INPUT_TYPE, List<OUTPUT_TYPE>> matchedAction) {
MatchedMultiAction<INPUT_TYPE, OUTPUT_TYPE> adaptMatchedAction = ctx
-> matchedAction.apply(ctx.root);
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/mv/SelectMaterializedIndexWithAggregate.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/mv/SelectMaterializedIndexWithAggregate.java
index b41fdc2d4e8..abc842cb9a8 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/mv/SelectMaterializedIndexWithAggregate.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/mv/SelectMaterializedIndexWithAggregate.java
@@ -105,7 +105,7 @@ public class SelectMaterializedIndexWithAggregate extends
AbstractSelectMaterial
return ImmutableList.of(
// only agg above scan
// Aggregate(Scan)
-
logicalAggregate(logicalOlapScan().when(this::shouldSelectIndexWithAgg)).thenApply(ctx
-> {
+
logicalAggregate(logicalOlapScan().when(this::shouldSelectIndexWithAgg)).thenApplyNoThrow(ctx
-> {
LogicalAggregate<LogicalOlapScan> agg = ctx.root;
LogicalOlapScan scan = agg.child();
SelectResult result = select(
@@ -140,7 +140,7 @@ public class SelectMaterializedIndexWithAggregate extends
AbstractSelectMaterial
// filter could push down scan.
// Aggregate(Filter(Scan))
logicalAggregate(logicalFilter(logicalOlapScan().when(this::shouldSelectIndexWithAgg)))
- .thenApply(ctx -> {
+ .thenApplyNoThrow(ctx -> {
LogicalAggregate<LogicalFilter<LogicalOlapScan>>
agg = ctx.root;
LogicalFilter<LogicalOlapScan> filter =
agg.child();
LogicalOlapScan scan = filter.child();
@@ -191,7 +191,7 @@ public class SelectMaterializedIndexWithAggregate extends
AbstractSelectMaterial
// column pruning or other projections such as alias, etc.
// Aggregate(Project(Scan))
logicalAggregate(logicalProject(logicalOlapScan().when(this::shouldSelectIndexWithAgg)))
- .thenApply(ctx -> {
+ .thenApplyNoThrow(ctx -> {
LogicalAggregate<LogicalProject<LogicalOlapScan>>
agg = ctx.root;
LogicalProject<LogicalOlapScan> project =
agg.child();
LogicalOlapScan scan = project.child();
@@ -240,7 +240,7 @@ public class SelectMaterializedIndexWithAggregate extends
AbstractSelectMaterial
// filter could push down and project.
// Aggregate(Project(Filter(Scan)))
logicalAggregate(logicalProject(logicalFilter(logicalOlapScan()
- .when(this::shouldSelectIndexWithAgg)))).thenApply(ctx
-> {
+
.when(this::shouldSelectIndexWithAgg)))).thenApplyNoThrow(ctx -> {
LogicalAggregate<LogicalProject<LogicalFilter<LogicalOlapScan>>> agg = ctx.root;
LogicalProject<LogicalFilter<LogicalOlapScan>>
project = agg.child();
LogicalFilter<LogicalOlapScan> filter =
project.child();
@@ -298,7 +298,7 @@ public class SelectMaterializedIndexWithAggregate extends
AbstractSelectMaterial
// filter can't push down
// Aggregate(Filter(Project(Scan)))
logicalAggregate(logicalFilter(logicalProject(logicalOlapScan()
- .when(this::shouldSelectIndexWithAgg)))).thenApply(ctx
-> {
+
.when(this::shouldSelectIndexWithAgg)))).thenApplyNoThrow(ctx -> {
LogicalAggregate<LogicalFilter<LogicalProject<LogicalOlapScan>>> agg = ctx.root;
LogicalFilter<LogicalProject<LogicalOlapScan>>
filter = agg.child();
LogicalProject<LogicalOlapScan> project =
filter.child();
@@ -354,7 +354,7 @@ public class SelectMaterializedIndexWithAggregate extends
AbstractSelectMaterial
// only agg above scan
// Aggregate(Repeat(Scan))
logicalAggregate(
-
logicalRepeat(logicalOlapScan().when(this::shouldSelectIndexWithAgg))).thenApply(ctx
-> {
+
logicalRepeat(logicalOlapScan().when(this::shouldSelectIndexWithAgg))).thenApplyNoThrow(ctx
-> {
LogicalAggregate<LogicalRepeat<LogicalOlapScan>> agg =
ctx.root;
LogicalRepeat<LogicalOlapScan> repeat = agg.child();
LogicalOlapScan scan = repeat.child();
@@ -396,7 +396,7 @@ public class SelectMaterializedIndexWithAggregate extends
AbstractSelectMaterial
// filter could push down scan.
// Aggregate(Repeat(Filter(Scan)))
logicalAggregate(logicalRepeat(logicalFilter(logicalOlapScan().when(this::shouldSelectIndexWithAgg))))
- .thenApply(ctx -> {
+ .thenApplyNoThrow(ctx -> {
LogicalAggregate<LogicalRepeat<LogicalFilter<LogicalOlapScan>>> agg = ctx.root;
LogicalRepeat<LogicalFilter<LogicalOlapScan>>
repeat = agg.child();
LogicalFilter<LogicalOlapScan> filter =
repeat.child();
@@ -454,7 +454,7 @@ public class SelectMaterializedIndexWithAggregate extends
AbstractSelectMaterial
// column pruning or other projections such as alias, etc.
// Aggregate(Repeat(Project(Scan)))
logicalAggregate(logicalRepeat(logicalProject(logicalOlapScan().when(this::shouldSelectIndexWithAgg))))
- .thenApply(ctx -> {
+ .thenApplyNoThrow(ctx -> {
LogicalAggregate<LogicalRepeat<LogicalProject<LogicalOlapScan>>> agg = ctx.root;
LogicalRepeat<LogicalProject<LogicalOlapScan>>
repeat = agg.child();
LogicalProject<LogicalOlapScan> project =
repeat.child();
@@ -509,7 +509,7 @@ public class SelectMaterializedIndexWithAggregate extends
AbstractSelectMaterial
// filter could push down and project.
// Aggregate(Repeat(Project(Filter(Scan))))
logicalAggregate(logicalRepeat(logicalProject(logicalFilter(logicalOlapScan()
-
.when(this::shouldSelectIndexWithAgg))))).thenApply(ctx -> {
+
.when(this::shouldSelectIndexWithAgg))))).thenApplyNoThrow(ctx -> {
LogicalAggregate<LogicalRepeat<LogicalProject
<LogicalFilter<LogicalOlapScan>>>> agg =
ctx.root;
LogicalRepeat<LogicalProject<LogicalFilter<LogicalOlapScan>>> repeat =
agg.child();
@@ -576,7 +576,7 @@ public class SelectMaterializedIndexWithAggregate extends
AbstractSelectMaterial
// filter can't push down
// Aggregate(Repeat(Filter(Project(Scan))))
logicalAggregate(logicalRepeat(logicalFilter(logicalProject(logicalOlapScan()
-
.when(this::shouldSelectIndexWithAgg))))).thenApply(ctx -> {
+
.when(this::shouldSelectIndexWithAgg))))).thenApplyNoThrow(ctx -> {
LogicalAggregate<LogicalRepeat<LogicalFilter
<LogicalProject<LogicalOlapScan>>>> agg =
ctx.root;
LogicalRepeat<LogicalFilter<LogicalProject<LogicalOlapScan>>> repeat =
agg.child();
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/mv/SelectMaterializedIndexWithoutAggregate.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/mv/SelectMaterializedIndexWithoutAggregate.java
index 2ad22b00316..7787df22c7f 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/mv/SelectMaterializedIndexWithoutAggregate.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/mv/SelectMaterializedIndexWithoutAggregate.java
@@ -62,7 +62,7 @@ public class SelectMaterializedIndexWithoutAggregate extends
AbstractSelectMater
// project with pushdown filter.
// Project(Filter(Scan))
logicalProject(logicalFilter(logicalOlapScan().when(this::shouldSelectIndexWithoutAgg)))
- .thenApply(ctx -> {
+ .thenApplyNoThrow(ctx -> {
LogicalProject<LogicalFilter<LogicalOlapScan>>
project = ctx.root;
LogicalFilter<LogicalOlapScan> filter =
project.child();
LogicalOlapScan scan = filter.child();
@@ -82,7 +82,7 @@ public class SelectMaterializedIndexWithoutAggregate extends
AbstractSelectMater
// project with filter that cannot be pushdown.
// Filter(Project(Scan))
logicalFilter(logicalProject(logicalOlapScan().when(this::shouldSelectIndexWithoutAgg)))
- .thenApply(ctx -> {
+ .thenApplyNoThrow(ctx -> {
LogicalFilter<LogicalProject<LogicalOlapScan>>
filter = ctx.root;
LogicalProject<LogicalOlapScan> project =
filter.child();
LogicalOlapScan scan = project.child();
@@ -101,7 +101,7 @@ public class SelectMaterializedIndexWithoutAggregate
extends AbstractSelectMater
// scan with filters could be pushdown.
// Filter(Scan)
logicalFilter(logicalOlapScan().when(this::shouldSelectIndexWithoutAgg))
- .thenApply(ctx -> {
+ .thenApplyNoThrow(ctx -> {
LogicalFilter<LogicalOlapScan> filter = ctx.root;
LogicalOlapScan scan = filter.child();
LogicalOlapScan mvPlan = select(
@@ -120,7 +120,7 @@ public class SelectMaterializedIndexWithoutAggregate
extends AbstractSelectMater
// project and scan.
// Project(Scan)
logicalProject(logicalOlapScan().when(this::shouldSelectIndexWithoutAgg))
- .thenApply(ctx -> {
+ .thenApplyNoThrow(ctx -> {
LogicalProject<LogicalOlapScan> project = ctx.root;
LogicalOlapScan scan = project.child();
@@ -139,7 +139,7 @@ public class SelectMaterializedIndexWithoutAggregate
extends AbstractSelectMater
// only scan.
logicalOlapScan()
.when(this::shouldSelectIndexWithoutAgg)
- .thenApply(ctx -> {
+ .thenApplyNoThrow(ctx -> {
LogicalOlapScan scan = ctx.root;
LogicalOlapScan mvPlan = select(
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]