Skip to content

Commit

Permalink
fix duplicated properties is not reported
Browse files Browse the repository at this point in the history
  • Loading branch information
xiedeyantu committed Mar 23, 2024
1 parent 2c01739 commit 2d09478
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1249,14 +1249,21 @@ private static ReplicaAllocation analyzeReplicaAllocationImpl(Map<String, String
if (properties == null || properties.isEmpty()) {
return ReplicaAllocation.NOT_SET;
}
String propKey = Strings.isNullOrEmpty(prefix) ? PROPERTIES_REPLICATION_ALLOCATION
: prefix + "." + PROPERTIES_REPLICATION_ALLOCATION;

// if give "replication_num" property, return with default backend tag
Short replicaNum = analyzeReplicationNum(properties, prefix, (short) 0);
if (replicaNum > 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"""

}

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 {
}
}

0 comments on commit 2d09478

Please sign in to comment.