This is an automated email from the ASF dual-hosted git repository. yangbowen pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push: new 958fa5c763d fix syntax error for CreateTableLikeStmt with partition properties (#34187) 958fa5c763d is described below commit 958fa5c763d9b96b03bac658202f65b954330b23 Author: Xujian Duan <50550370+darvend...@users.noreply.github.com> AuthorDate: Mon Apr 29 11:03:42 2024 +0800 fix syntax error for CreateTableLikeStmt with partition properties (#34187) fix syntax error for CreateTableLikeStmt with partition properties --- .../apache/doris/catalog/ListPartitionInfo.java | 3 +- .../apache/doris/catalog/RangePartitionInfo.java | 3 +- .../suites/ddl_p0/test_create_table_like.groovy | 54 ++++++++++++++++++++++ 3 files changed, 58 insertions(+), 2 deletions(-) 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 d657dc7d9d4..ce8d4303cbe 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 9a6c5d353fd..caa77f660bd 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 a1154c05a43..f4c1da02d93 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 --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org