morrySnow commented on code in PR #51700:
URL: https://github.com/apache/doris/pull/51700#discussion_r2144164437
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/NereidsPlanner.java:
##########
@@ -427,8 +413,13 @@ protected void rewrite(boolean showPlanProcess) {
statementContext.getConnectContext().getExecutor().getSummaryProfile().setNereidsRewriteTime();
}
// collect partitions table used, this is for query rewrite by
materialized view
- // this is needed before init hook
- collectTableUsedPartitions(showPlanProcess);
+ // this is needed before init hook, because
+
MaterializedViewUtils.collectTableUsedPartitions(cascadesContext.getRewritePlan(),
cascadesContext);
Review Comment:
why not do it in hook?
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/mv/StructInfo.java:
##########
@@ -752,10 +752,13 @@ public static Pair<Plan, Boolean>
addFilterOnTableScan(Plan queryPlan, Map<BaseT
queryPlanWithUnionFilter = new LogicalPlanDeepCopier().deepCopy(
(LogicalPlan) queryPlanWithUnionFilter, new
DeepCopierContext());
// rbo rewrite after adding filter on origin plan
- return
Pair.of(MaterializedViewUtils.rewriteByRules(parentCascadesContext, context -> {
+ Plan filterAddedPlan =
MaterializedViewUtils.rewriteByRules(parentCascadesContext, context -> {
Rewriter.getWholeTreeRewriter(context).execute();
return context.getRewritePlan();
- }, queryPlanWithUnionFilter, queryPlan), true);
+ }, queryPlanWithUnionFilter, queryPlan);
+ // need to collect table partition again
Review Comment:
write why need re-collect here in comment
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/mv/StructInfo.java:
##########
@@ -752,10 +752,13 @@ public static Pair<Plan, Boolean>
addFilterOnTableScan(Plan queryPlan, Map<BaseT
queryPlanWithUnionFilter = new LogicalPlanDeepCopier().deepCopy(
(LogicalPlan) queryPlanWithUnionFilter, new
DeepCopierContext());
// rbo rewrite after adding filter on origin plan
- return
Pair.of(MaterializedViewUtils.rewriteByRules(parentCascadesContext, context -> {
+ Plan filterAddedPlan =
MaterializedViewUtils.rewriteByRules(parentCascadesContext, context -> {
Rewriter.getWholeTreeRewriter(context).execute();
return context.getRewritePlan();
- }, queryPlanWithUnionFilter, queryPlan), true);
+ }, queryPlanWithUnionFilter, queryPlan);
+ // need to collect table partition again
+ MaterializedViewUtils.collectTableUsedPartitions(filterAddedPlan,
parentCascadesContext);
Review Comment:
if u need collect partition info multi times, u should sum the time used by
it in summary profile
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/mv/StructInfo.java:
##########
@@ -752,10 +752,13 @@ public static Pair<Plan, Boolean>
addFilterOnTableScan(Plan queryPlan, Map<BaseT
queryPlanWithUnionFilter = new LogicalPlanDeepCopier().deepCopy(
(LogicalPlan) queryPlanWithUnionFilter, new
DeepCopierContext());
// rbo rewrite after adding filter on origin plan
- return
Pair.of(MaterializedViewUtils.rewriteByRules(parentCascadesContext, context -> {
+ Plan filterAddedPlan =
MaterializedViewUtils.rewriteByRules(parentCascadesContext, context -> {
Rewriter.getWholeTreeRewriter(context).execute();
return context.getRewritePlan();
- }, queryPlanWithUnionFilter, queryPlan), true);
+ }, queryPlanWithUnionFilter, queryPlan);
+ // need to collect table partition again
+ MaterializedViewUtils.collectTableUsedPartitions(filterAddedPlan,
parentCascadesContext);
Review Comment:
only collect for sub plan is enough?
--
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]