This is an automated email from the ASF dual-hosted git repository.
cambyzju pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.0 by this push:
new fbf3b52385b [fix](coldheat) fix missing partition's storage policy in
create_table_like stmt (#47145)
fbf3b52385b is described below
commit fbf3b52385bab65b42f46c5f956de0ce52655555
Author: Yulei-Yang <[email protected]>
AuthorDate: Mon Jan 20 10:55:50 2025 +0800
[fix](coldheat) fix missing partition's storage policy in create_table_like
stmt (#47145)
---
.../apache/doris/catalog/ListPartitionInfo.java | 4 ++
.../apache/doris/catalog/RangePartitionInfo.java | 3 ++
.../create_table_use_partition_policy.groovy | 55 +++++++++++++++++++++-
3 files changed, 61 insertions(+), 1 deletion(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/catalog/ListPartitionInfo.java
b/fe/fe-core/src/main/java/org/apache/doris/catalog/ListPartitionInfo.java
index 8683005f37e..3c32e336eb2 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/catalog/ListPartitionInfo.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/ListPartitionInfo.java
@@ -222,6 +222,10 @@ public class ListPartitionInfo extends PartitionInfo {
}
sb.append(")");
+ if (!"".equals(getStoragePolicy(entry.getKey()))) {
+ sb.append("(\"storage_policy\" =
\"").append(getStoragePolicy(entry.getKey())).append("\")");
+ }
+
if (partitionId != null) {
partitionId.add(entry.getKey());
break;
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/catalog/RangePartitionInfo.java
b/fe/fe-core/src/main/java/org/apache/doris/catalog/RangePartitionInfo.java
index bea50593c3f..87ac9e20d32 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/catalog/RangePartitionInfo.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/RangePartitionInfo.java
@@ -277,6 +277,9 @@ public class RangePartitionInfo extends PartitionInfo {
sb.append("PARTITION ").append(partitionName).append(" VALUES [");
sb.append(range.lowerEndpoint().toSql());
sb.append(", ").append(range.upperEndpoint().toSql()).append(")");
+ if (!"".equals(getStoragePolicy(entry.getKey()))) {
+ sb.append("(\"storage_policy\" =
\"").append(getStoragePolicy(entry.getKey())).append("\")");
+ }
if (partitionId != null) {
partitionId.add(entry.getKey());
diff --git
a/regression-test/suites/cold_heat_separation/empty_table_use_policy/create_table_use_partition_policy.groovy
b/regression-test/suites/cold_heat_separation/empty_table_use_policy/create_table_use_partition_policy.groovy
index 7307392147a..3fff811f33b 100644
---
a/regression-test/suites/cold_heat_separation/empty_table_use_policy/create_table_use_partition_policy.groovy
+++
b/regression-test/suites/cold_heat_separation/empty_table_use_policy/create_table_use_partition_policy.groovy
@@ -140,11 +140,64 @@ suite("create_table_use_partition_policy") {
) PARTITION BY RANGE (k1) (
PARTITION p1 VALUES LESS THAN ("2022-01-01 00:00:00.111")
("storage_policy" = "test_create_table_partition_use_policy_1"
,"replication_num"="1"),
PARTITION p2 VALUES LESS THAN ("2022-02-01 00:00:00.111")
("storage_policy" = "test_create_table_partition_use_policy_2"
,"replication_num"="1")
- ) DISTRIBUTED BY HASH(k2) BUCKETS 1;
+ ) DISTRIBUTED BY HASH(k2) BUCKETS 1
+ PROPERTIES (
+ "replication_num" = "1"
+ );
"""
assertEquals(create_table_partition_use_created_policy_2.size(), 1);
+ // test create table like
+ sql """
+ CREATE TABLE create_table_partition_use_created_policy_3 LIKE
create_table_partition_use_created_policy_2;
+ """
+ def policy_using_item_count_1 = try_sql """
+ SHOW STORAGE POLICY USING for test_create_table_partition_use_policy_1
+ """
+ assertEquals(policy_using_item_count_1.size(), 2);
+
+ def policy_using_item_count_2 = try_sql """
+ SHOW STORAGE POLICY USING for test_create_table_partition_use_policy_2
+ """
+ assertEquals(policy_using_item_count_2.size(), 2);
+
+ def create_table_partition_use_created_policy_4 = try_sql """
+ CREATE TABLE IF NOT EXISTS create_table_partition_use_created_policy_4
+ (
+ k1 DATE NOT NULL,
+ k2 INT,
+ V1 VARCHAR(2048) REPLACE
+ ) PARTITION BY LIST (k1) (
+ PARTITION p1 VALUES IN ("2022-01-01") ("storage_policy" =
"test_create_table_partition_use_policy_1" ,"replication_num"="1"),
+ PARTITION p2 VALUES IN ("2022-02-01") ("storage_policy" =
"test_create_table_partition_use_policy_2" ,"replication_num"="1")
+ ) DISTRIBUTED BY HASH(k2) BUCKETS 1
+ PROPERTIES (
+ "replication_num" = "1"
+ );
+ """
+ sql """
+ CREATE TABLE create_table_partition_use_created_policy_5 LIKE
create_table_partition_use_created_policy_4;
+ """
+ def policy_using_item_count_3 = try_sql """
+ SHOW STORAGE POLICY USING for test_create_table_partition_use_policy_1
+ """
+ assertEquals(policy_using_item_count_3.size(), 4);
+
+ def policy_using_item_count_4 = try_sql """
+ SHOW STORAGE POLICY USING for test_create_table_partition_use_policy_2
+ """
+ assertEquals(policy_using_item_count_4.size(), 4);
+
+ sql """
+ DROP TABLE create_table_partition_use_created_policy_5;
+ """
+ sql """
+ DROP TABLE create_table_partition_use_created_policy_4;
+ """
+ sql """
+ DROP TABLE create_table_partition_use_created_policy_3;
+ """
sql """
DROP TABLE create_table_partition_use_created_policy_2;
"""
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]