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 d657dc7d9d..ce8d4303cb 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 @@ -28,6 +28,7 @@ import org.apache.doris.analysis.SlotRef; import org.apache.doris.common.AnalysisException; import org.apache.doris.common.DdlException; import org.apache.doris.common.util.ListUtil; +import org.apache.doris.common.util.PropertyAnalyzer; import com.google.common.base.Preconditions; import com.google.common.collect.Lists; @@ -249,7 +250,7 @@ public class ListPartitionInfo extends PartitionInfo { Optional.ofNullable(this.idToStoragePolicy.get(entry.getKey())).ifPresent(p -> { if (!p.equals("")) { - sb.append("PROPERTIES (\"STORAGE POLICY\" = \""); + sb.append(" (\"" + PropertyAnalyzer.PROPERTIES_STORAGE_POLICY + "\" = \""); sb.append(p).append("\")"); } }); 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 9a6c5d353f..caa77f660b 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 @@ -25,6 +25,7 @@ import org.apache.doris.analysis.RangePartitionDesc; import org.apache.doris.analysis.SinglePartitionDesc; import org.apache.doris.common.AnalysisException; import org.apache.doris.common.DdlException; +import org.apache.doris.common.util.PropertyAnalyzer; import org.apache.doris.common.util.RangeUtils; import com.google.common.base.Preconditions; @@ -299,7 +300,7 @@ public class RangePartitionInfo extends PartitionInfo { Optional.ofNullable(this.idToStoragePolicy.get(entry.getKey())).ifPresent(p -> { if (!p.equals("")) { - sb.append("PROPERTIES (\"STORAGE POLICY\" = \""); + sb.append(" (\"" + PropertyAnalyzer.PROPERTIES_STORAGE_POLICY + "\" = \""); sb.append(p).append("\")"); } }); diff --git a/regression-test/suites/ddl_p0/test_create_table_like.groovy b/regression-test/suites/ddl_p0/test_create_table_like.groovy index a1154c05a4..f4c1da02d9 100644 --- a/regression-test/suites/ddl_p0/test_create_table_like.groovy +++ b/regression-test/suites/ddl_p0/test_create_table_like.groovy @@ -47,4 +47,58 @@ suite("test_create_table_like") { VALUES ("test1", 1, 123456789, 1234567891, 123456789, 1234567891, 123456789)""" qt_select_table_like """select * from decimal_test_like""" + + def resource_name = "test_create_table_like_use_resource" + def policy_name = "test_create_table_like_use_policy" + def table1 = "create_table_partion_use_created_policy" + def table2 = "create_table_partion_like_use_created_policy" + + sql """ + CREATE RESOURCE IF NOT EXISTS $resource_name + PROPERTIES( + "type"="s3", + "AWS_REGION" = "bj", + "AWS_ENDPOINT" = "bj.s3.comaaaa", + "AWS_ROOT_PATH" = "path/to/rootaaaa", + "AWS_SECRET_KEY" = "aaaa", + "AWS_ACCESS_KEY" = "bbba", + "AWS_BUCKET" = "test-bucket", + "s3_validity_check" = "false" + ); + """ + sql """ + CREATE STORAGE POLICY IF NOT EXISTS $policy_name + PROPERTIES( + "storage_resource" = "$resource_name", + "cooldown_ttl" = "10" + ); + """ + + sql """DROP TABLE IF EXISTS $table1""" + sql """DROP TABLE IF EXISTS $table2""" + + sql """ + CREATE TABLE $table1 + ( + k1 DATE, + k2 INT, + V1 VARCHAR(2048) REPLACE + ) PARTITION BY RANGE (k1) ( + PARTITION p1 VALUES LESS THAN ("2022-01-01") ("storage_policy" = "$policy_name"), + PARTITION p2 VALUES LESS THAN ("2022-02-01") ("storage_policy" = "$policy_name") + ) + DISTRIBUTED BY HASH(k2) BUCKETS 1 + PROPERTIES ( + "replication_num"="1" + ); + """ + + sql """ + CREATE TABLE $table2 LIKE $table1 + """ + + sql """DROP TABLE IF EXISTS $table1""" + sql """DROP TABLE IF EXISTS $table2""" + sql """DROP STORAGE POLICY $policy_name""" + sql """DROP RESOURCE $resource_name""" } \ No newline at end of file