Skip to content

Commit ffbf6c2

Browse files
committed
1
1 parent e4af923 commit ffbf6c2

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

fe/fe-core/src/main/java/org/apache/doris/datasource/InternalCatalog.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1608,6 +1608,11 @@ public PartitionPersistInfo addPartition(Database db, String tableName, AddParti
16081608
}
16091609
}
16101610

1611+
if (partitionInfo.getType() != PartitionType.RANGE && partitionInfo.getType() != PartitionType.LIST
1612+
&& !isTempPartition) {
1613+
throw new DdlException("Alter table [" + olapTable.getName() + "] failed. Not a partitioned table");
1614+
}
1615+
16111616
Map<String, String> properties = singlePartitionDesc.getProperties();
16121617

16131618
/*
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
suite("test_add_partition_exception") {
19+
sql "drop table if exists test_create_table_exception_tbl"
20+
sql """
21+
CREATE TABLE IF NOT EXISTS test_create_table_exception_tbl (
22+
k1 int NOT NULL,
23+
k2 bigint NOT NULL
24+
)
25+
DISTRIBUTED BY HASH(k1) BUCKETS 5 properties("replication_num" = "1")
26+
"""
27+
28+
test{
29+
sql """ alter table test_create_table_exception_tbl add partition p0 values in (("1"))"""
30+
exception "Alter table [test_create_table_exception_tbl] failed. Not a partitioned table"
31+
}
32+
}

0 commit comments

Comments
 (0)