Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -574,22 +574,22 @@ public static Map<String, String> analyzeDynamicPartition(Map<String, String> 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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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') """
Expand Down