diff --git a/fe/fe-core/src/main/java/org/apache/doris/common/util/DynamicPartitionUtil.java b/fe/fe-core/src/main/java/org/apache/doris/common/util/DynamicPartitionUtil.java index ff2c9433057347..1dc2d81dd7c156 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/common/util/DynamicPartitionUtil.java +++ b/fe/fe-core/src/main/java/org/apache/doris/common/util/DynamicPartitionUtil.java @@ -574,22 +574,22 @@ public static Map analyzeDynamicPartition(Map pr // If create_history_partition is true, will pre-create history partition according the valid value from // start and history_partition_num. // - int expectCreatePartitionNum = 0; + long expectCreatePartitionNum = 0; if (!createHistoryPartition) { start = 0; - expectCreatePartitionNum = end - start; + expectCreatePartitionNum = (long) end - start; } else { int historyPartitionNum = Integer.parseInt(analyzedProperties.getOrDefault( DynamicPartitionProperty.HISTORY_PARTITION_NUM, String.valueOf(DynamicPartitionProperty.NOT_SET_HISTORY_PARTITION_NUM))); if (historyPartitionNum != DynamicPartitionProperty.NOT_SET_HISTORY_PARTITION_NUM) { - expectCreatePartitionNum = end - Math.max(start, -historyPartitionNum); + expectCreatePartitionNum = (long) end - Math.max(start, -historyPartitionNum); } else { if (start == Integer.MIN_VALUE) { throw new DdlException("Provide start or history_partition_num property" - + " when creating history partition"); + + " when create_history_partition=true. Otherwise set create_history_partition=false"); } - expectCreatePartitionNum = end - start; + expectCreatePartitionNum = (long) end - start; } } if (hasEnd && (expectCreatePartitionNum > Config.max_dynamic_partition_num) diff --git a/fe/fe-core/src/test/java/org/apache/doris/catalog/DynamicPartitionTableTest.java b/fe/fe-core/src/test/java/org/apache/doris/catalog/DynamicPartitionTableTest.java index 74f72303ab3025..f5493dedb76c00 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/catalog/DynamicPartitionTableTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/catalog/DynamicPartitionTableTest.java @@ -641,7 +641,8 @@ public void testFillHistoryDynamicPartition3() throws Exception { + ");"; // start and history_partition_num are not set, can not create history partition ExceptionChecker.expectThrowsWithMsg(DdlException.class, - "Provide start or history_partition_num property when creating history partition", + "Provide start or history_partition_num property when create_history_partition=true. " + + "Otherwise set create_history_partition=false", () -> createTable(createOlapTblStmt)); String createOlapTblStmt2 = "CREATE TABLE test.`dynamic_partition3` (\n" diff --git a/regression-test/suites/partition_p0/dynamic_partition/test_dynamic_partition_with_alter.groovy b/regression-test/suites/partition_p0/dynamic_partition/test_dynamic_partition_with_alter.groovy index a88761d23c706d..a844ad7549dcc9 100644 --- a/regression-test/suites/partition_p0/dynamic_partition/test_dynamic_partition_with_alter.groovy +++ b/regression-test/suites/partition_p0/dynamic_partition/test_dynamic_partition_with_alter.groovy @@ -34,9 +34,20 @@ suite("test_dynamic_partition_with_alter") { "dynamic_partition.create_history_partition"="true", "dynamic_partition.replication_allocation" = "tag.location.default: 1") """ + result = sql "show partitions from ${tbl}" assertEquals(7, result.size()) + test { + sql "alter table ${tbl} set ('dynamic_partition.start' = '-2147483648')" + exception "Provide start or history_partition_num property" + } + + test { + sql "alter table ${tbl} set ('dynamic_partition.start' = '-2147483647')" + exception "Too many dynamic partitions" + } + // modify distributed column comment, then try to add too more dynamic partition sql """ alter table ${tbl} modify column k1 comment 'new_comment_for_k1' """ sql """ ADMIN SET FRONTEND CONFIG ('dynamic_partition_check_interval_seconds' = '1') """