This is an automated email from the ASF dual-hosted git repository. dataroaring 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 d5a3f0ab49f branch-3.0: [fix](partition) Add partition of mismatched type to table #47200 (#47446) d5a3f0ab49f is described below commit d5a3f0ab49ffc17f4aeda4e951fbd78f23bfa123 Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> AuthorDate: Wed Feb 19 11:00:26 2025 +0800 branch-3.0: [fix](partition) Add partition of mismatched type to table #47200 (#47446) Cherry-picked from #47200 Co-authored-by: Uniqueyou <wangyix...@selectdb.com> --- .../apache/doris/analysis/PartitionKeyDesc.java | 4 ++ .../apache/doris/catalog/ListPartitionInfo.java | 4 ++ .../apache/doris/catalog/RangePartitionInfo.java | 3 ++ .../test_partition_add_mismatched.groovy | 48 ++++++++++++++++++++++ 4 files changed, 59 insertions(+) diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/PartitionKeyDesc.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/PartitionKeyDesc.java index 4cd87953572..223576a52c2 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/PartitionKeyDesc.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/PartitionKeyDesc.java @@ -144,6 +144,10 @@ public class PartitionKeyDesc { return partitionKeyValueType; } + public boolean hasInValues() { + return inValues != null; + } + public void analyze(int partColNum) throws AnalysisException { if (isDummy()) { return; 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 9d6fb63b269..3134d7d3b3f 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 @@ -81,6 +81,10 @@ public class ListPartitionInfo extends PartitionInfo { // get partition key PartitionKeyDesc partitionKeyDesc = desc.getPartitionKeyDesc(); + if (!partitionKeyDesc.hasInValues()) { + throw new DdlException("List partition expected 'VALUES [IN or ((\"xxx\", \"xxx\"), ...)]'"); + } + // we might receive one whole empty values list, we should add default partition value for // such occasion for (List<PartitionValue> values : partitionKeyDesc.getInValues()) { 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 6378a8d6c00..f4d7ac631ed 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 @@ -86,6 +86,9 @@ public class RangePartitionInfo extends PartitionInfo { Range<PartitionKey> newRange = null; PartitionKeyDesc partitionKeyDesc = desc.getPartitionKeyDesc(); // check range + if (partitionKeyDesc.hasInValues()) { + throw new DdlException("Range partition expected 'VALUES [LESS THAN or [(\"xxx\" ,...), (\"xxx\", ...))]'"); + } try { newRange = createAndCheckNewRange(partitionKeyDesc, isTemp); } catch (AnalysisException e) { diff --git a/regression-test/suites/partition_p0/test_partition_add_mismatched.groovy b/regression-test/suites/partition_p0/test_partition_add_mismatched.groovy new file mode 100644 index 00000000000..e9182b9fab6 --- /dev/null +++ b/regression-test/suites/partition_p0/test_partition_add_mismatched.groovy @@ -0,0 +1,48 @@ +// 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. + +suite("test_partition_add_mismatched") { + sql "drop table if exists test_partition_add_mismatched_list_tbl" + sql """ + CREATE TABLE IF NOT EXISTS test_partition_add_mismatched_list_tbl ( + k1 int NOT NULL, + k2 bigint NOT NULL + ) + PARTITION BY LIST(k1,k2) () + DISTRIBUTED BY HASH(k1) BUCKETS 5 properties("replication_num" = "1") + """ + + sql "drop table if exists test_partition_add_mismatched_range_tbl" + sql """ + CREATE TABLE IF NOT EXISTS test_partition_add_mismatched_range_tbl ( + k1 int NOT NULL, + k2 bigint NOT NULL + ) + PARTITION BY RANGE(k1,k2) () + DISTRIBUTED BY HASH(k1) BUCKETS 5 properties("replication_num" = "1") + """ + + test{ + sql """ alter table test_partition_add_mismatched_list_tbl add partition p0 values [("0"), ("2")) """ + exception "List partition expected 'VALUES [IN or ((\"xxx\", \"xxx\"), ...)]'" + } + + test{ + sql """ alter table test_partition_add_mismatched_range_tbl add partition p0 values in (("0", "2")) """ + exception "Range partition expected 'VALUES [LESS THAN or [(\"xxx\" ,...), (\"xxx\", ...))]'" + } +} --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org