diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/ColocateGroupSchema.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/ColocateGroupSchema.java index 32c48c5fba..40b3405069 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/ColocateGroupSchema.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/ColocateGroupSchema.java @@ -116,18 +116,15 @@ public class ColocateGroupSchema implements Writable { } private void checkReplicaAllocation(PartitionInfo partitionInfo) throws DdlException { - for (ReplicaAllocation replicaAlloc : partitionInfo.idToReplicaAllocation.values()) { - if (!replicaAlloc.equals(this.replicaAlloc)) { - ErrorReport.reportDdlException(ErrorCode.ERR_COLOCATE_TABLE_MUST_HAS_SAME_REPLICATION_ALLOCATION, - this.replicaAlloc); - } + for (ReplicaAllocation alloc : partitionInfo.idToReplicaAllocation.values()) { + checkReplicaAllocation(alloc); } } public void checkReplicaAllocation(ReplicaAllocation replicaAlloc) throws DdlException { if (!replicaAlloc.equals(this.replicaAlloc)) { ErrorReport.reportDdlException(ErrorCode.ERR_COLOCATE_TABLE_MUST_HAS_SAME_REPLICATION_ALLOCATION, - this.replicaAlloc); + replicaAlloc, this.replicaAlloc); } } diff --git a/fe/fe-core/src/main/java/org/apache/doris/common/ErrorCode.java b/fe/fe-core/src/main/java/org/apache/doris/common/ErrorCode.java index 95c65c7bbd..c36821fd99 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/common/ErrorCode.java +++ b/fe/fe-core/src/main/java/org/apache/doris/common/ErrorCode.java @@ -1110,7 +1110,7 @@ public enum ErrorCode { ERR_COLOCATE_TABLE_MUST_BE_OLAP_TABLE(5063, new byte[]{'4', '2', '0', '0', '0'}, "Colocate table '%s' must be OLAP table"), ERR_COLOCATE_TABLE_MUST_HAS_SAME_REPLICATION_ALLOCATION(5063, new byte[]{'4', '2', '0', '0', '0'}, - "Colocate tables must have same replication allocation: %s"), + "Colocate tables must have same replication allocation: { %s } should be { %s }"), ERR_COLOCATE_TABLE_MUST_HAS_SAME_BUCKET_NUM(5063, new byte[]{'4', '2', '0', '0', '0'}, "Colocate tables must have same bucket num: %s"), ERR_COLOCATE_TABLE_MUST_HAS_SAME_DISTRIBUTION_COLUMN_SIZE(5063, new byte[]{'4', '2', '0', '0', '0'}, diff --git a/fe/fe-core/src/test/java/org/apache/doris/catalog/ColocateTableTest.java b/fe/fe-core/src/test/java/org/apache/doris/catalog/ColocateTableTest.java index 4ea69f0394..87b5180843 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/catalog/ColocateTableTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/catalog/ColocateTableTest.java @@ -252,7 +252,8 @@ public class ColocateTableTest { + ");"); expectedEx.expect(DdlException.class); - expectedEx.expectMessage("Colocate tables must have same replication allocation: tag.location.default: 1"); + expectedEx.expectMessage("Colocate tables must have same replication allocation: { tag.location.default: 2 }" + + " should be { tag.location.default: 1 }"); createTable("create table " + dbName + "." + tableName2 + " (\n" + " `k1` int NULL COMMENT \"\",\n" + " `k2` varchar(10) NULL COMMENT \"\"\n" diff --git a/regression-test/suites/schema_change_p0/test_alter_colocate_table.groovy b/regression-test/suites/schema_change_p0/test_alter_colocate_table.groovy index aac70b46e1..ce23f70a3e 100644 --- a/regression-test/suites/schema_change_p0/test_alter_colocate_table.groovy +++ b/regression-test/suites/schema_change_p0/test_alter_colocate_table.groovy @@ -37,6 +37,9 @@ suite ("test_alter_colocate_table") { } assertFalse(existsGroup) + def forceReplicaNum = getFeConfig('force_olap_table_replication_num') as int + def replicaNum = forceReplicaNum > 0 ? forceReplicaNum : 1 + sql """ CREATE TABLE IF NOT EXISTS col_tbl1 ( @@ -48,7 +51,7 @@ suite ("test_alter_colocate_table") { DISTRIBUTED BY HASH(k2) BUCKETS 3 PROPERTIES ( - "replication_allocation" = "tag.location.default:1", + "replication_allocation" = "tag.location.default:${replicaNum}", "colocate_with" = 'x_group_1' ) """ @@ -69,7 +72,7 @@ suite ("test_alter_colocate_table") { DISTRIBUTED BY HASH(k2) BUCKETS 3 PROPERTIES ( - "replication_allocation" = "tag.location.default:1", + "replication_allocation" = "tag.location.default:${replicaNum}", "colocate_with" = 'x_group_2' ) """ @@ -85,7 +88,7 @@ suite ("test_alter_colocate_table") { DISTRIBUTED BY HASH(uuid) BUCKETS 3 PROPERTIES ( - "replication_allocation" = "tag.location.default:1", + "replication_allocation" = "tag.location.default:${replicaNum}", "colocate_with" = "x_group_3", "dynamic_partition.enable" = "true", "dynamic_partition.time_unit" = "DAY", @@ -94,7 +97,7 @@ suite ("test_alter_colocate_table") { "dynamic_partition.buckets" = "3", "dynamic_partition.replication_num" = "1", "dynamic_partition.create_history_partition"= "true", - "dynamic_partition.replication_allocation" = "tag.location.default:1", + "dynamic_partition.replication_allocation" = "tag.location.default:${replicaNum}", "dynamic_partition.start" = "-3" ); """ @@ -104,7 +107,7 @@ suite ("test_alter_colocate_table") { test { sql """ ALTER TABLE col_tbl1 set ( - "replication_allocation" = "tag.location.default:1" + "replication_allocation" = "tag.location.default:${replicaNum}" ) """ exception errMsg @@ -113,7 +116,7 @@ suite ("test_alter_colocate_table") { test { sql """ ALTER TABLE col_tbl3 set ( - "dynamic_partition.replication_allocation" = "tag.location.default:1" + "dynamic_partition.replication_allocation" = "tag.location.default:${replicaNum}" ) """ exception errMsg @@ -123,7 +126,7 @@ suite ("test_alter_colocate_table") { test { sql """ ALTER TABLE ${tbl} set ( - "default.replication_allocation" = "tag.location.default:1" + "default.replication_allocation" = "tag.location.default:${replicaNum}" ) """ @@ -133,7 +136,7 @@ suite ("test_alter_colocate_table") { test { sql """ ALTER TABLE ${tbl} MODIFY PARTITION (*) set ( - "replication_allocation" = "tag.location.default:1" + "replication_allocation" = "tag.location.default:${replicaNum}" ) """