This is an automated email from the ASF dual-hosted git repository.

yangyulei pushed a commit to branch branch-3.0
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-3.0 by this push:
     new f24c3ee6413 branch-3.0: [fix](coldheat) fix missing partition's 
storage policy in create_table_like stmt #47009 (#47183)
f24c3ee6413 is described below

commit f24c3ee6413102968650140c84e388af582d1153
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Tue Jan 21 12:19:47 2025 +0800

    branch-3.0: [fix](coldheat) fix missing partition's storage policy in 
create_table_like stmt #47009 (#47183)
    
    Cherry-picked from #47009
    
    Co-authored-by: Yulei-Yang <yulei.yang0...@gmail.com>
---
 .../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 bc08ef47e98..9d6fb63b269 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
@@ -219,6 +219,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 d0e738553ad..6378a8d6c00 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
@@ -297,6 +297,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..aad1b5f1655 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,
+            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: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to