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

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


The following commit(s) were added to refs/heads/branch-2.1 by this push:
     new 11fecd123d5 branch-2.1: [fix](gson) Missing the serialization of the 
partition's storage policy #49721 (#49841)
11fecd123d5 is described below

commit 11fecd123d5bef068ad61b6a5af8aa1ccbb94619
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Tue Apr 8 11:02:13 2025 +0800

    branch-2.1: [fix](gson) Missing the serialization of the partition's 
storage policy #49721 (#49841)
    
    Cherry-picked from #49721
    
    Co-authored-by: Uniqueyou <wangyix...@selectdb.com>
---
 .../org/apache/doris/catalog/PartitionInfo.java    |   1 +
 .../test_partition_serialized_sp.groovy            | 134 +++++++++++++++++++++
 2 files changed, 135 insertions(+)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/catalog/PartitionInfo.java 
b/fe/fe-core/src/main/java/org/apache/doris/catalog/PartitionInfo.java
index 2c81e8e2aba..1ba46b50926 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/catalog/PartitionInfo.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/PartitionInfo.java
@@ -69,6 +69,7 @@ public class PartitionInfo implements Writable {
     @SerializedName("IdToDataProperty")
     protected Map<Long, DataProperty> idToDataProperty;
     // partition id -> storage policy
+    @SerializedName("IdToStoragePolicy")
     protected Map<Long, String> idToStoragePolicy;
     // partition id -> replication allocation
     @SerializedName("IdToReplicaAllocation")
diff --git 
a/regression-test/suites/partition_p0/test_partition_serialized_sp.groovy 
b/regression-test/suites/partition_p0/test_partition_serialized_sp.groovy
new file mode 100644
index 00000000000..eb3d5b70fe2
--- /dev/null
+++ b/regression-test/suites/partition_p0/test_partition_serialized_sp.groovy
@@ -0,0 +1,134 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+import org.apache.doris.regression.suite.ClusterOptions
+
+suite('test_partition_serialized_sp', 'docker') {
+    def resourceName = "test_partition_serialized_sp_resource"
+    def policyName= "test_partition_serialized_sp_policy"
+    def tableName = "test_partition_serialized_sp_table"
+
+    def options = new ClusterOptions()
+    options.feNum = 1
+    options.beNum = 1
+    
+    docker(options) {
+        logger.info("Starting test_partition_serialized_sp test...")
+        def check_storage_policy_exist = { name->
+            def polices = sql"""
+            show storage policy;
+            """
+            for (p in polices) {
+                if (name == p[0]) {
+                    return true;
+                }
+            }
+            return false;
+        }
+
+        if (check_storage_policy_exist(policyName)) {
+            sql """
+                DROP STORAGE POLICY ${policyName}
+            """
+        }
+
+        def has_resource = sql """
+            SHOW RESOURCES WHERE NAME = "${resourceName}";
+        """
+
+        if (has_resource.size() > 0) {
+            sql """
+                DROP RESOURCE ${resourceName}
+            """
+        }
+
+        sql """
+            CREATE RESOURCE IF NOT EXISTS "${resourceName}"
+            PROPERTIES(
+                "type"="s3",
+                "AWS_ENDPOINT" = "${getS3Endpoint()}",
+                "AWS_REGION" = "${getS3Region()}",
+                "AWS_ROOT_PATH" = "regression/cooldown",
+                "AWS_ACCESS_KEY" = "${getS3AK()}",
+                "AWS_SECRET_KEY" = "${getS3SK()}",
+                "AWS_MAX_CONNECTIONS" = "50",
+                "AWS_REQUEST_TIMEOUT_MS" = "3000",
+                "AWS_CONNECTION_TIMEOUT_MS" = "1000",
+                "AWS_BUCKET" = "${getS3BucketName()}",
+                "s3_validity_check" = "false"
+            );
+        """
+
+        sql """
+        CREATE STORAGE POLICY ${policyName}
+        PROPERTIES(
+            "storage_resource" = "${resourceName}",
+            "cooldown_ttl" = "1d"
+        );
+        """
+        
+        logger.info("Created storage policy: ${policyName}")
+
+        sql "DROP TABLE IF EXISTS ${tableName}"
+        
+        sql """
+        CREATE TABLE IF NOT EXISTS ${tableName} (
+            id INT,
+            ts DATETIME,
+            name VARCHAR(50)
+        )
+        PARTITION BY RANGE(ts) (
+            PARTITION p1 VALUES LESS THAN ("2023-01-01 00:00:00") 
("storage_policy" = "${policyName}"),
+            PARTITION p2 VALUES LESS THAN ("2023-02-01 00:00:00") 
("storage_policy" = "${policyName}"),
+            PARTITION p3 VALUES LESS THAN ("2023-03-01 00:00:00") 
("storage_policy" = "${policyName}")
+        )
+        DISTRIBUTED BY HASH(id) BUCKETS 3
+        PROPERTIES("replication_num" = "1");
+        """
+        
+        logger.info("Created partitioned table with storage policy")
+        
+        sql """
+        INSERT INTO ${tableName} VALUES 
+        (1, "2022-12-15 12:00:00", "test1"),
+        (2, "2023-01-15 12:00:00", "test2"),
+        (3, "2023-02-15 12:00:00", "test3");
+        """
+        
+        def res = sql """ SHOW CREATE TABLE ${tableName} """
+
+        assertTrue(res[0][1].contains("\"${policyName}\""))
+        
+        logger.info("All partitions have correct storage policy before 
restart")
+        
+        logger.info("Restarting Doris cluster...")
+        cluster.restartFrontends()
+        sleep(20000)
+        context.reconnectFe()
+        logger.info("Successfully reconnected to the frontend")
+        
+        res = sql """ SHOW CREATE TABLE ${tableName} """
+
+        assertTrue(res[0][1].contains("\"${policyName}\""))
+        
+        def result = sql """
+        SELECT * FROM ${tableName} ORDER BY id;
+        """
+        
+        assertEquals(result.size(), 3)
+    }
+}
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to