[fix](mtmv) Fix get mv statistics plan wrong and optimize code usage (#35623)
1. get mv statistics, the relation id should be getted from scan plan, fix it. 2. optimize the `isGroupEquals` method, add `MaterializationContext` param which maybe used to control the decide group by equals logic. 3. remove `set enable_nereids_timeout = false;` setting in mv rewrite regression test.
This commit is contained in:
@ -94,7 +94,7 @@ public abstract class AbstractMaterializedViewAggregateRule extends AbstractMate
|
||||
// Firstly,if group by expression between query and view is equals, try to rewrite expression directly
|
||||
Plan queryTopPlan = queryTopPlanAndAggPair.key();
|
||||
if (isGroupByEquals(queryTopPlanAndAggPair, viewTopPlanAndAggPair, viewToQuerySlotMapping, queryStructInfo,
|
||||
viewStructInfo)) {
|
||||
viewStructInfo, materializationContext)) {
|
||||
List<Expression> rewrittenQueryExpressions = rewriteExpression(queryTopPlan.getOutput(),
|
||||
queryTopPlan,
|
||||
materializationContext.getExprToScanExprMapping(),
|
||||
@ -253,7 +253,8 @@ public abstract class AbstractMaterializedViewAggregateRule extends AbstractMate
|
||||
Pair<Plan, LogicalAggregate<Plan>> viewTopPlanAndAggPair,
|
||||
SlotMapping viewToQuerySlotMapping,
|
||||
StructInfo queryStructInfo,
|
||||
StructInfo viewStructInfo) {
|
||||
StructInfo viewStructInfo,
|
||||
MaterializationContext materializationContext) {
|
||||
Plan queryTopPlan = queryTopPlanAndAggPair.key();
|
||||
Plan viewTopPlan = viewTopPlanAndAggPair.key();
|
||||
LogicalAggregate<Plan> queryAggregate = queryTopPlanAndAggPair.value();
|
||||
|
||||
@ -103,9 +103,9 @@ public class AsyncMaterializationContext extends MaterializationContext {
|
||||
return Optional.empty();
|
||||
}
|
||||
RelationId relationId = null;
|
||||
List<Object> scanObjs = this.getPlan().collectFirst(plan -> plan instanceof LogicalOlapScan);
|
||||
if (scanObjs != null && !scanObjs.isEmpty()) {
|
||||
relationId = ((LogicalOlapScan) scanObjs.get(0)).getRelationId();
|
||||
List<LogicalOlapScan> logicalOlapScan = this.getScanPlan().collectFirst(LogicalOlapScan.class::isInstance);
|
||||
if (!logicalOlapScan.isEmpty()) {
|
||||
relationId = logicalOlapScan.get(0).getRelationId();
|
||||
}
|
||||
return Optional.of(Pair.of(relationId, mtmvCache.getStatistics()));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user