This is an automated email from the ASF dual-hosted git repository.

kxiao pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.0 by this push:
     new a376f0c8cc0 [fix](dynamic partition) fix create too many dynamic 
partitions (#30994) (#31039)
a376f0c8cc0 is described below

commit a376f0c8cc0915b919a872fe84a48009c13814b3
Author: yujun <yu.jun.re...@gmail.com>
AuthorDate: Sun Feb 18 17:55:26 2024 +0800

    [fix](dynamic partition) fix create too many dynamic partitions (#30994) 
(#31039)
---
 .../org/apache/doris/common/util/DynamicPartitionUtil.java    | 10 +++++-----
 .../org/apache/doris/catalog/DynamicPartitionTableTest.java   |  3 ++-
 .../test_dynamic_partition_with_alter.groovy                  | 11 +++++++++++
 3 files changed, 18 insertions(+), 6 deletions(-)

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 fcd578d9bc7..6587da5aef6 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
@@ -569,22 +569,22 @@ public class DynamicPartitionUtil {
         // 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 22c19fb159b..f883f8928fc 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 class DynamicPartitionTableTest {
                 + ");";
         // 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 a88761d23c7..a844ad7549d 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') """


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to