Skip to content

Commit 00465ef

Browse files
committed
fix alter add incorrect partition properties
1 parent 55bed10 commit 00465ef

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/PartitionDefinition.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ public void validate(Map<String, String> otherProperties) {
9797
}
9898

9999
Map<String, String> mergedMap = Maps.newHashMap();
100+
// validate should not change partitionDesc properties
101+
Map<String, String> oldProperties = this.properties == null ? null : Maps.newHashMap(this.properties);
100102
// Should putAll `otherProperties` before `this.properties`,
101103
// because the priority of partition is higher than table
102104
if (otherProperties != null) {
@@ -141,6 +143,7 @@ public void validate(Map<String, String> otherProperties) {
141143
}
142144
}
143145
}
146+
this.properties = oldProperties; // recover properties
144147
} catch (Exception e) {
145148
throw new AnalysisException(e.getMessage(), e.getCause());
146149
}

regression-test/suites/alter_p2/test_alter_table_property.groovy

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,5 +89,37 @@ suite ("test_alter_table_property") {
8989
assertTrue(createTableStr.contains("\"storage_medium\" = \"ssd\""))
9090

9191
sql "DROP TABLE ${tableName}"
92+
93+
tableName = "test_alter_table_partition_property_table"
94+
sql "DROP TABLE IF EXISTS ${tableName}"
95+
sql """
96+
CREATE TABLE IF NOT EXISTS ${tableName}
97+
(
98+
k1 DATETIME(3),
99+
k2 INT,
100+
V1 VARCHAR(2048) REPLACE
101+
)
102+
PARTITION BY RANGE(k1)
103+
(
104+
PARTITION p1 VALUES LESS THAN ("2022-01-01 00:00:00.111"),
105+
PARTITION p2 VALUES LESS THAN ("2022-02-01 00:00:00.111")
106+
)
107+
DISTRIBUTED BY HASH(k2) BUCKETS 2
108+
PROPERTIES (
109+
"replication_num" = "1",
110+
"mutable" = "true"
111+
)
112+
"""
113+
114+
sql """ALTER TABLE ${tableName} ADD PARTITION p3 VALUES LESS THAN ("2022-03-01 00:00:00.111") ("mutable" = "false")"""
115+
116+
def partitions = sql """SHOW PARTITIONS FROM ${tableName} where PartitionName = "p3" """
117+
logger.info("partitions: $partitions")
118+
def lastPartition = partitions[-1]
119+
logger.info("lastPartition: $lastPartition")
120+
def isMutable = lastPartition[-5]
121+
122+
logger.info("p3 IsMutable: ${isMutable}")
123+
assertEquals('false', isMutable)
92124
}
93125

0 commit comments

Comments
 (0)