morrySnow commented on code in PR #25715:
URL: https://github.com/apache/doris/pull/25715#discussion_r1373990792
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/mv/SelectMaterializedIndexWithAggregate.java:
##########
@@ -106,545 +106,671 @@ public List<Rule> buildRules() {
// only agg above scan
// Aggregate(Scan)
logicalAggregate(logicalOlapScan().when(this::shouldSelectIndex)).thenApply(ctx
-> {
- LogicalAggregate<LogicalOlapScan> agg = ctx.root;
- LogicalOlapScan scan = agg.child();
- SelectResult result = select(
- scan,
- agg.getInputSlots(),
- ImmutableSet.of(),
- extractAggFunctionAndReplaceSlot(agg,
Optional.empty()),
- agg.getGroupByExpressions(),
- new HashSet<>(agg.getExpressions()));
-
- LogicalOlapScan mvPlan =
scan.withMaterializedIndexSelected(result.preAggStatus, result.indexId);
- SlotContext slotContext =
generateBaseScanExprToMvExpr(mvPlan);
-
- if (result.exprRewriteMap.isEmpty()) {
- return new ReplaceExpressions(slotContext)
- .replace(agg.withChildren(mvPlan), mvPlan);
- } else {
- return new LogicalProject<>(
- generateProjectsAlias(agg.getOutputs(),
slotContext),
- new ReplaceExpressions(slotContext).replace(
- new LogicalAggregate<>(
- agg.getGroupByExpressions(),
- replaceAggOutput(
- agg, Optional.empty(),
Optional.empty(), result.exprRewriteMap),
- agg.isNormalized(),
- agg.getSourceRepeat(),
- mvPlan
- ), mvPlan));
+ try {
+ LogicalAggregate<LogicalOlapScan> agg = ctx.root;
+ LogicalOlapScan scan = agg.child();
+ SelectResult result = select(scan,
agg.getInputSlots(), ImmutableSet.of(),
+ extractAggFunctionAndReplaceSlot(agg,
Optional.empty()),
+ agg.getGroupByExpressions(), new
HashSet<>(agg.getExpressions()));
+
+ LogicalOlapScan mvPlan = scan
+
.withMaterializedIndexSelected(result.preAggStatus, result.indexId);
+ SlotContext slotContext =
generateBaseScanExprToMvExpr(mvPlan);
+
+ if (result.exprRewriteMap.isEmpty()) {
+ return new ReplaceExpressions(slotContext)
+ .replace(agg.withChildren(mvPlan), mvPlan);
+ } else {
+ return new LogicalProject<>(
+ generateProjectsAlias(agg.getOutputs(),
slotContext),
+ new ReplaceExpressions(slotContext)
+ .replace(
+ new LogicalAggregate<>(
+
agg.getGroupByExpressions(),
+
replaceAggOutput(agg, Optional.empty(),
+
Optional.empty(),
+
result.exprRewriteMap),
+ agg.isNormalized(),
+
agg.getSourceRepeat(), mvPlan),
+ mvPlan));
+ }
+ } catch (Exception ex) {
Review Comment:
add log
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/mv/SelectMaterializedIndexWithAggregate.java:
##########
@@ -106,545 +106,671 @@ public List<Rule> buildRules() {
// only agg above scan
// Aggregate(Scan)
logicalAggregate(logicalOlapScan().when(this::shouldSelectIndex)).thenApply(ctx
-> {
- LogicalAggregate<LogicalOlapScan> agg = ctx.root;
- LogicalOlapScan scan = agg.child();
- SelectResult result = select(
- scan,
- agg.getInputSlots(),
- ImmutableSet.of(),
- extractAggFunctionAndReplaceSlot(agg,
Optional.empty()),
- agg.getGroupByExpressions(),
- new HashSet<>(agg.getExpressions()));
-
- LogicalOlapScan mvPlan =
scan.withMaterializedIndexSelected(result.preAggStatus, result.indexId);
- SlotContext slotContext =
generateBaseScanExprToMvExpr(mvPlan);
-
- if (result.exprRewriteMap.isEmpty()) {
- return new ReplaceExpressions(slotContext)
- .replace(agg.withChildren(mvPlan), mvPlan);
- } else {
- return new LogicalProject<>(
- generateProjectsAlias(agg.getOutputs(),
slotContext),
- new ReplaceExpressions(slotContext).replace(
- new LogicalAggregate<>(
- agg.getGroupByExpressions(),
- replaceAggOutput(
- agg, Optional.empty(),
Optional.empty(), result.exprRewriteMap),
- agg.isNormalized(),
- agg.getSourceRepeat(),
- mvPlan
- ), mvPlan));
+ try {
Review Comment:
i think the better way is add a new interface `thenApplyNoThrow`. do try
catch in it
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]