You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by mo...@apache.org on 2024/06/07 13:09:48 UTC
(doris) branch branch-2.1 updated: [fix](mtmv)fix mtmv show partition error when base table dropped (#35729) (#36051)
This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.1 by this push:
new 5148c3908e3 [fix](mtmv)fix mtmv show partition error when base table dropped (#35729) (#36051)
5148c3908e3 is described below
commit 5148c3908e3c72dc63837d106c366778de826cdf
Author: zhangdong <49...@qq.com>
AuthorDate: Fri Jun 7 21:09:41 2024 +0800
[fix](mtmv)fix mtmv show partition error when base table dropped (#35729) (#36051)
bp #35729
---
.../doris/common/proc/PartitionsProcDir.java | 23 +++++--
.../org/apache/doris/mtmv/MTMVPartitionUtil.java | 4 +-
.../mtmv_p0/test_show_partitions_mtmv.groovy | 72 ++++++++++++++++++++++
3 files changed, 92 insertions(+), 7 deletions(-)
diff --git a/fe/fe-core/src/main/java/org/apache/doris/common/proc/PartitionsProcDir.java b/fe/fe-core/src/main/java/org/apache/doris/common/proc/PartitionsProcDir.java
index 6b8f59e6508..19e2ac6b6bb 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/common/proc/PartitionsProcDir.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/common/proc/PartitionsProcDir.java
@@ -52,6 +52,7 @@ import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList;
import java.util.Collection;
@@ -245,10 +246,14 @@ public class PartitionsProcDir implements ProcDirInterface {
Joiner joiner = Joiner.on(", ");
Map<Long, List<String>> partitionsUnSyncTables = null;
+ String mtmvPartitionSyncErrorMsg = null;
if (olapTable instanceof MTMV) {
- partitionsUnSyncTables = MTMVPartitionUtil
- .getPartitionsUnSyncTables((MTMV) olapTable, partitionIds);
-
+ try {
+ partitionsUnSyncTables = MTMVPartitionUtil
+ .getPartitionsUnSyncTables((MTMV) olapTable, partitionIds);
+ } catch (AnalysisException e) {
+ mtmvPartitionSyncErrorMsg = e.getMessage();
+ }
}
for (Long partitionId : partitionIds) {
Partition partition = olapTable.getPartition(partitionId);
@@ -314,9 +319,15 @@ public class PartitionsProcDir implements ProcDirInterface {
partitionInfo.add(tblPartitionInfo.getIsMutable(partitionId));
if (olapTable instanceof MTMV) {
- List<String> partitionUnSyncTables = partitionsUnSyncTables.get(partitionId);
- partitionInfo.add(CollectionUtils.isEmpty(partitionUnSyncTables));
- partitionInfo.add(partitionUnSyncTables.toString());
+ if (StringUtils.isEmpty(mtmvPartitionSyncErrorMsg)) {
+ List<String> partitionUnSyncTables = partitionsUnSyncTables.getOrDefault(partitionId,
+ Lists.newArrayList());
+ partitionInfo.add(CollectionUtils.isEmpty(partitionUnSyncTables));
+ partitionInfo.add(partitionUnSyncTables.toString());
+ } else {
+ partitionInfo.add(false);
+ partitionInfo.add(mtmvPartitionSyncErrorMsg);
+ }
} else {
partitionInfo.add(true);
partitionInfo.add(FeConstants.null_string);
diff --git a/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVPartitionUtil.java b/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVPartitionUtil.java
index f2b7b146ee5..82a649be37c 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVPartitionUtil.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVPartitionUtil.java
@@ -266,7 +266,9 @@ public class MTMVPartitionUtil {
if (mtmv.getMvPartitionInfo().getPartitionType() != MTMVPartitionType.SELF_MANAGE && mtmv
.getMvPartitionInfo().getRelatedTableInfo().equals(baseTableInfo)) {
if (CollectionUtils.isEmpty(relatedPartitionNames)) {
- throw new AnalysisException("can not found related partition");
+ // can not found related partition
+ res.add(mtmvRelatedTableIf.getName());
+ continue;
}
boolean isSyncWithPartition = isSyncWithPartitions(mtmv, partitionName, mtmvRelatedTableIf,
relatedPartitionNames);
diff --git a/regression-test/suites/mtmv_p0/test_show_partitions_mtmv.groovy b/regression-test/suites/mtmv_p0/test_show_partitions_mtmv.groovy
new file mode 100644
index 00000000000..3575cbd80e1
--- /dev/null
+++ b/regression-test/suites/mtmv_p0/test_show_partitions_mtmv.groovy
@@ -0,0 +1,72 @@
+// 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.
+
+import org.junit.Assert;
+
+suite("test_show_partitions_mtmv","mtmv") {
+ String suiteName = "test_show_partitions_mtmv"
+ String tableName = "${suiteName}_table"
+ String mvName = "${suiteName}_mv"
+ sql """drop table if exists `${tableName}`"""
+ sql """drop materialized view if exists ${mvName};"""
+
+ sql """
+ CREATE TABLE ${tableName}
+ (
+ k2 TINYINT,
+ k3 INT not null
+ )
+ COMMENT "my first table"
+ PARTITION BY LIST(`k3`)
+ (
+ PARTITION `p1` VALUES IN ('1'),
+ PARTITION `p2` VALUES IN ('2'),
+ PARTITION `p3` VALUES IN ('3')
+ )
+ DISTRIBUTED BY HASH(k2) BUCKETS 2
+ PROPERTIES (
+ "replication_num" = "1"
+ );
+ """
+ sql """
+ CREATE MATERIALIZED VIEW ${mvName}
+ BUILD DEFERRED REFRESH AUTO ON MANUAL
+ partition by(`k3`)
+ DISTRIBUTED BY RANDOM BUCKETS 2
+ PROPERTIES (
+ 'replication_num' = '1'
+ )
+ AS
+ SELECT * from ${tableName};
+ """
+
+ // drop partition of base table
+ sql """
+ alter table ${tableName} drop partition p1;
+ """
+ def dropPartitionResult = sql """show partitions from ${mvName}"""
+ logger.info("dropPartitionResult: " + dropPartitionResult.toString())
+
+ // drop base table
+ sql """drop table if exists `${tableName}`"""
+
+ def dropTableResult = sql """show partitions from ${mvName}"""
+ logger.info("dropTableResult: " + dropTableResult.toString())
+
+ sql """drop table if exists `${tableName}`"""
+ sql """drop materialized view if exists ${mvName};"""
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org