zddr commented on code in PR #31812: URL: https://github.com/apache/doris/pull/31812#discussion_r1597789288
########## fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/MTMVPartitionDefinition.java: ########## @@ -0,0 +1,225 @@ +// 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. +// This file is copied from +// https://github.com/apache/impala/blob/branch-2.9.0/fe/src/main/java/org/apache/impala/Expr.java +// and modified by Doris + +package org.apache.doris.nereids.trees.plans.commands.info; + +import org.apache.doris.analysis.Expr; +import org.apache.doris.analysis.FunctionCallExpr; +import org.apache.doris.analysis.FunctionParams; +import org.apache.doris.analysis.SlotRef; +import org.apache.doris.analysis.StringLiteral; +import org.apache.doris.common.DdlException; +import org.apache.doris.datasource.hive.HMSExternalTable; +import org.apache.doris.mtmv.MTMVPartitionExprFactory; +import org.apache.doris.mtmv.MTMVPartitionInfo; +import org.apache.doris.mtmv.MTMVPartitionInfo.MTMVPartitionType; +import org.apache.doris.mtmv.MTMVRelatedTableIf; +import org.apache.doris.mtmv.MTMVUtil; +import org.apache.doris.nereids.CascadesContext; +import org.apache.doris.nereids.NereidsPlanner; +import org.apache.doris.nereids.analyzer.UnboundFunction; +import org.apache.doris.nereids.analyzer.UnboundSlot; +import org.apache.doris.nereids.exceptions.AnalysisException; +import org.apache.doris.nereids.properties.PhysicalProperties; +import org.apache.doris.nereids.rules.exploration.mv.MaterializedViewUtils; +import org.apache.doris.nereids.rules.exploration.mv.MaterializedViewUtils.RelatedTableInfo; +import org.apache.doris.nereids.trees.expressions.Expression; +import org.apache.doris.nereids.trees.expressions.literal.Literal; +import org.apache.doris.nereids.trees.plans.Plan; +import org.apache.doris.nereids.trees.plans.commands.ExplainCommand.ExplainLevel; +import org.apache.doris.nereids.trees.plans.logical.LogicalPlan; +import org.apache.doris.qe.ConnectContext; +import org.apache.doris.qe.SessionVariable; + +import com.google.common.collect.Lists; +import com.google.common.collect.Sets; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import java.util.Set; +import java.util.stream.Collectors; + +/** + * MTMVPartitionDefinition + */ +public class MTMVPartitionDefinition { + private MTMVPartitionType partitionType; + private String partitionCol; + private Expression functionCallExpression; + + /** + * analyzeAndTransferToMTMVPartitionInfo + * + * @param planner planner + * @param ctx ctx + * @param logicalQuery logicalQuery + * @return MTMVPartitionInfo + */ + public MTMVPartitionInfo analyzeAndTransferToMTMVPartitionInfo(NereidsPlanner planner, ConnectContext ctx, + LogicalPlan logicalQuery) { + MTMVPartitionInfo mtmvPartitionInfo = new MTMVPartitionInfo(partitionType); + if (this.partitionType == MTMVPartitionType.SELF_MANAGE) { + return mtmvPartitionInfo; + } + String partitionColName; + if (this.partitionType == MTMVPartitionType.EXPR) { + Expr expr = convertToLegacyAutoPartitionExprs(Lists.newArrayList(functionCallExpression)) + .get(0); + partitionColName = getColNameFromExpr(expr); + mtmvPartitionInfo.setExpr(expr); + } else { + partitionColName = this.partitionCol; + } + mtmvPartitionInfo.setPartitionCol(partitionColName); + RelatedTableInfo relatedTableInfo = getRelatedTableInfo(planner, ctx, logicalQuery, partitionColName); + mtmvPartitionInfo.setRelatedCol(relatedTableInfo.getColumn()); + mtmvPartitionInfo.setRelatedTable(relatedTableInfo.getTableInfo()); + if (this.partitionType == MTMVPartitionType.EXPR) { + try { + MTMVPartitionExprFactory.getExprSerice(mtmvPartitionInfo.getExpr()).analyze(mtmvPartitionInfo); Review Comment: service -- 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: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org