From 2d094789f16c09f15b4684ab7cd92d7998c9ca0b Mon Sep 17 00:00:00 2001 From: xiedeyantu Date: Sun, 24 Mar 2024 00:09:50 +0800 Subject: [PATCH 1/3] fix duplicated properties is not reported --- .../doris/common/util/PropertyAnalyzer.java | 13 ++++++++--- .../test_create_table_properties.groovy | 22 ++++++++++++++++++- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/common/util/PropertyAnalyzer.java b/fe/fe-core/src/main/java/org/apache/doris/common/util/PropertyAnalyzer.java index 3b4a8472fc103a1..8f9e70ddee1a614 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/common/util/PropertyAnalyzer.java +++ b/fe/fe-core/src/main/java/org/apache/doris/common/util/PropertyAnalyzer.java @@ -1249,14 +1249,21 @@ private static ReplicaAllocation analyzeReplicaAllocationImpl(Map 0) { - return new ReplicaAllocation(replicaNum); + ReplicaAllocation replicaAlloc = new ReplicaAllocation(replicaNum); + if (properties.get(propKey).equals(replicaAlloc.toString())) { + throw new AnalysisException("Invalid replication parameter: replication_num and " + + "replication_allocation can not be used together"); + } + return replicaAlloc; } - String propKey = Strings.isNullOrEmpty(prefix) ? PROPERTIES_REPLICATION_ALLOCATION - : prefix + "." + PROPERTIES_REPLICATION_ALLOCATION; + // if not set, return default replication allocation if (!properties.containsKey(propKey)) { return ReplicaAllocation.NOT_SET; diff --git a/regression-test/suites/ddl_p0/test_create_table_properties.groovy b/regression-test/suites/ddl_p0/test_create_table_properties.groovy index c6908d80b07cda3..77fb344ec9455f0 100644 --- a/regression-test/suites/ddl_p0/test_create_table_properties.groovy +++ b/regression-test/suites/ddl_p0/test_create_table_properties.groovy @@ -401,4 +401,24 @@ suite("test_create_table_properties") { qt_select """ select * from ${tblName1} partition p5 order by DATA_STAMP""" qt_select """ select * from ${tblName1} partition p8 order by DATA_STAMP""" -} \ No newline at end of file + + try { + sql "drop table if exists ${tblName1}" + sql """ + CREATE TABLE ${tblName1} ( + id int, + k decimal(12,2) + ) ENGINE=OLAP + DISTRIBUTED BY HASH(id) BUCKETS 1 + PROPERTIES ( + "replication_allocation" = "tag.location.default: 1", + "replication_num" = "1" + ); + """ + assertTrue(false, "should not be able to execute") + } + catch (Exception ex) { + assertTrue(ex.getMessage().contains("Invalid replication parameter: replication_num and replication_allocation can not be used together")) + } finally { + } +} From 20165426302539226ef88a4eb859d3f0590504f5 Mon Sep 17 00:00:00 2001 From: chen Date: Sun, 24 Mar 2024 06:58:02 +0800 Subject: [PATCH 2/3] Update PropertyAnalyzer.java --- .../java/org/apache/doris/common/util/PropertyAnalyzer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/common/util/PropertyAnalyzer.java b/fe/fe-core/src/main/java/org/apache/doris/common/util/PropertyAnalyzer.java index 8f9e70ddee1a614..c1685e0f180abf9 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/common/util/PropertyAnalyzer.java +++ b/fe/fe-core/src/main/java/org/apache/doris/common/util/PropertyAnalyzer.java @@ -1256,7 +1256,7 @@ private static ReplicaAllocation analyzeReplicaAllocationImpl(Map 0) { ReplicaAllocation replicaAlloc = new ReplicaAllocation(replicaNum); - if (properties.get(propKey).equals(replicaAlloc.toString())) { + if (properties.containsKey(propKey) && properties.get(propKey).equals(replicaAlloc.toString())) { throw new AnalysisException("Invalid replication parameter: replication_num and " + "replication_allocation can not be used together"); } From da0f7440b0f133a099f40819f6c45d8b33909009 Mon Sep 17 00:00:00 2001 From: xiedeyantu Date: Sun, 24 Mar 2024 10:28:33 +0800 Subject: [PATCH 3/3] fix test --- .../empty_table_use_policy/modify_partition_add_policy.groovy | 1 - .../modify_partition_add_policy_by_hdfs.groovy | 1 - 2 files changed, 2 deletions(-) diff --git a/regression-test/suites/cold_heat_separation/empty_table_use_policy/modify_partition_add_policy.groovy b/regression-test/suites/cold_heat_separation/empty_table_use_policy/modify_partition_add_policy.groovy index 467830b7e3df1de..fac15f46691b9fa 100644 --- a/regression-test/suites/cold_heat_separation/empty_table_use_policy/modify_partition_add_policy.groovy +++ b/regression-test/suites/cold_heat_separation/empty_table_use_policy/modify_partition_add_policy.groovy @@ -124,7 +124,6 @@ suite("add_table_policy_by_modify_partition") { PARTITION p2 VALUES LESS THAN ("2022-02-01") ("storage_policy" = "tmp2" ,"replication_num"="1") ) DISTRIBUTED BY HASH(k2) BUCKETS 1 PROPERTIES ( - "replication_allocation" = "tag.location.default: 1", "storage_policy" = "created_create_table_partition_alter_policy" ); """ diff --git a/regression-test/suites/cold_heat_separation/empty_table_use_policy/modify_partition_add_policy_by_hdfs.groovy b/regression-test/suites/cold_heat_separation/empty_table_use_policy/modify_partition_add_policy_by_hdfs.groovy index e6cbcd780ea88b3..e80b9448e969f09 100644 --- a/regression-test/suites/cold_heat_separation/empty_table_use_policy/modify_partition_add_policy_by_hdfs.groovy +++ b/regression-test/suites/cold_heat_separation/empty_table_use_policy/modify_partition_add_policy_by_hdfs.groovy @@ -125,7 +125,6 @@ suite("add_table_policy_by_modify_partition_hdfs") { PARTITION p2 VALUES LESS THAN ("2022-02-01") ("storage_policy" = "tmp2_hdfs" ,"replication_num"="1") ) DISTRIBUTED BY HASH(k2) BUCKETS 1 PROPERTIES ( - "replication_allocation" = "tag.location.default: 1", "storage_policy" = "created_create_table_partition_alter_policy_hdfs" ); """