[fix](mtmv) second level MTMV always refresh all partition by mistake… (#39167)
pick: https://github.com/apache/doris/pull/38698
This commit is contained in:
@ -196,7 +196,7 @@ public class MTMVTask extends AbstractTask {
|
||||
.subList(start, end > needRefreshPartitions.size() ? needRefreshPartitions.size() : end));
|
||||
// need get names before exec
|
||||
Map<String, MTMVRefreshPartitionSnapshot> execPartitionSnapshots = MTMVPartitionUtil
|
||||
.generatePartitionSnapshots(mtmv, relation.getBaseTables(), execPartitionNames,
|
||||
.generatePartitionSnapshots(mtmv, relation.getBaseTablesOneLevel(), execPartitionNames,
|
||||
partitionMappings);
|
||||
exec(ctx, execPartitionNames, tableWithPartKey);
|
||||
completedPartitions.addAll(execPartitionNames);
|
||||
@ -288,7 +288,7 @@ public class MTMVTask extends AbstractTask {
|
||||
* @throws DdlException
|
||||
*/
|
||||
private void refreshHmsTable() throws AnalysisException, DdlException {
|
||||
for (BaseTableInfo tableInfo : relation.getBaseTables()) {
|
||||
for (BaseTableInfo tableInfo : relation.getBaseTablesOneLevel()) {
|
||||
TableIf tableIf = MTMVUtil.getTable(tableInfo);
|
||||
if (tableIf instanceof HMSExternalTable) {
|
||||
HMSExternalTable hmsTable = (HMSExternalTable) tableIf;
|
||||
@ -450,7 +450,8 @@ public class MTMVTask extends AbstractTask {
|
||||
// check if data is fresh
|
||||
// We need to use a newly generated relationship and cannot retrieve it using mtmv.getRelation()
|
||||
// to avoid rebuilding the baseTable and causing a change in the tableId
|
||||
boolean fresh = MTMVPartitionUtil.isMTMVSync(mtmv, relation.getBaseTables(), mtmv.getExcludedTriggerTables(),
|
||||
boolean fresh = MTMVPartitionUtil.isMTMVSync(mtmv, relation.getBaseTablesOneLevel(),
|
||||
mtmv.getExcludedTriggerTables(),
|
||||
partitionMappings);
|
||||
if (fresh) {
|
||||
return Lists.newArrayList();
|
||||
@ -461,7 +462,8 @@ public class MTMVTask extends AbstractTask {
|
||||
}
|
||||
// We need to use a newly generated relationship and cannot retrieve it using mtmv.getRelation()
|
||||
// to avoid rebuilding the baseTable and causing a change in the tableId
|
||||
return MTMVPartitionUtil.getMTMVNeedRefreshPartitions(mtmv, relation.getBaseTables(), partitionMappings);
|
||||
return MTMVPartitionUtil.getMTMVNeedRefreshPartitions(mtmv, relation.getBaseTablesOneLevel(),
|
||||
partitionMappings);
|
||||
}
|
||||
|
||||
public MTMVTaskContext getTaskContext() {
|
||||
|
||||
@ -201,7 +201,8 @@ public class MTMVPartitionUtil {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
return isMTMVSync(mtmv, mtmvRelation.getBaseTables(), Sets.newHashSet(), mtmv.calculatePartitionMappings());
|
||||
return isMTMVSync(mtmv, mtmvRelation.getBaseTablesOneLevel(), Sets.newHashSet(),
|
||||
mtmv.calculatePartitionMappings());
|
||||
} catch (AnalysisException e) {
|
||||
LOG.warn("isMTMVSync failed: ", e);
|
||||
return false;
|
||||
@ -254,7 +255,7 @@ public class MTMVPartitionUtil {
|
||||
Set<String> relatedPartitionNames)
|
||||
throws AnalysisException {
|
||||
List<String> res = Lists.newArrayList();
|
||||
for (BaseTableInfo baseTableInfo : mtmv.getRelation().getBaseTables()) {
|
||||
for (BaseTableInfo baseTableInfo : mtmv.getRelation().getBaseTablesOneLevel()) {
|
||||
TableIf table = MTMVUtil.getTable(baseTableInfo);
|
||||
if (!(table instanceof MTMVRelatedTableIf)) {
|
||||
continue;
|
||||
|
||||
@ -71,7 +71,7 @@ public class MTMVRewriteUtil {
|
||||
partitionMappings = mtmv.calculatePartitionMappings();
|
||||
}
|
||||
if (MTMVPartitionUtil.isMTMVPartitionSync(mtmv, partition.getName(),
|
||||
partitionMappings.get(partition.getName()), mtmvRelation.getBaseTables(),
|
||||
partitionMappings.get(partition.getName()), mtmvRelation.getBaseTablesOneLevel(),
|
||||
Sets.newHashSet())) {
|
||||
res.add(partition);
|
||||
}
|
||||
|
||||
@ -85,7 +85,7 @@ public class MTMVUtil {
|
||||
* @return
|
||||
*/
|
||||
public static boolean mtmvContainsExternalTable(MTMV mtmv) {
|
||||
Set<BaseTableInfo> baseTables = mtmv.getRelation().getBaseTables();
|
||||
Set<BaseTableInfo> baseTables = mtmv.getRelation().getBaseTablesOneLevel();
|
||||
for (BaseTableInfo baseTableInfo : baseTables) {
|
||||
if (baseTableInfo.getCtlId() != InternalCatalog.INTERNAL_CATALOG_ID) {
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user