Skip to content

Commit

Permalink
[fix](dynamic partition) fix create dynamic partition with overlap no…
Browse files Browse the repository at this point in the history
…t throw exception #37924 (#37966)

cherry-pick: #37924
  • Loading branch information
yujun777 authored Jul 17, 2024
1 parent aca7ce9 commit 79b4154
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,11 @@ private ArrayList<AddPartitionClause> getAddPartitionClause(Database db, OlapTab
// IllegalArgumentException: lb is greater than ub
LOG.warn("Error in gen addPartitionKeyRange. db: {}, table: {}, partition idx: {}",
db.getFullName(), olapTable.getName(), idx, e);
recordCreatePartitionFailedMsg(db.getFullName(), olapTable.getName(),
e.getMessage(), olapTable.getId());
throw new DdlException(e.getMessage());
if (executeFirstTime) {
throw new DdlException("maybe dynamic_partition.start is too small, error: "
+ e.getMessage());
}
continue;
}
for (PartitionItem partitionItem : rangePartitionInfo.getIdToItem(false).values()) {
// only support single column partition now
Expand All @@ -298,7 +300,6 @@ private ArrayList<AddPartitionClause> getAddPartitionClause(Database db, OlapTab
addPartitionKeyRange, db.getFullName(), olapTable.getName(), idx, e);
recordCreatePartitionFailedMsg(db.getFullName(), olapTable.getName(),
e.getMessage(), olapTable.getId());
throw new DdlException(e.getMessage());
}
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ suite('test_dynamic_partition_failed', 'nonConcurrent') {
PROPERTIES
(
"replication_num" = "1",
"dynamic_partition.replication_num" = "1",
"dynamic_partition.enable" = "true",
"dynamic_partition.end" = "3",
"dynamic_partition.time_unit" = "day",
Expand All @@ -46,6 +47,26 @@ suite('test_dynamic_partition_failed', 'nonConcurrent') {

setFeConfig('max_dynamic_partition_num', Integer.MAX_VALUE)

sql 'DROP TABLE IF EXISTS test_dynamic_partition_failed_ok2 FORCE'
sql '''CREATE TABLE test_dynamic_partition_failed_ok2
( `k1` date NULL )
PARTITION BY RANGE(k1) (
PARTITION `phistory` VALUES less than ('2020-01-01')
)
DISTRIBUTED BY HASH(`k1`) BUCKETS 1
PROPERTIES
(
"replication_num" = "1",
"dynamic_partition.replication_num" = "1",
"dynamic_partition.enable" = "true",
"dynamic_partition.end" = "3",
"dynamic_partition.time_unit" = "YEAR",
"dynamic_partition.prefix" = "p",
"dynamic_partition.buckets" = "1",
"dynamic_partition.start" = "-10",
"dynamic_partition.create_history_partition" = "true"
)'''

sql 'DROP TABLE IF EXISTS test_dynamic_partition_failed_2'
test {
sql '''CREATE TABLE test_dynamic_partition_failed_2
Expand All @@ -55,6 +76,7 @@ suite('test_dynamic_partition_failed', 'nonConcurrent') {
PROPERTIES
(
"replication_num" = "1",
"dynamic_partition.replication_num" = "1",
"dynamic_partition.enable" = "true",
"dynamic_partition.end" = "3",
"dynamic_partition.time_unit" = "day",
Expand All @@ -74,6 +96,7 @@ suite('test_dynamic_partition_failed', 'nonConcurrent') {
} finally {
setFeConfig('max_dynamic_partition_num', old_max_dynamic_partition_num)
sql 'DROP TABLE IF EXISTS test_dynamic_partition_failed_ok1 FORCE'
sql 'DROP TABLE IF EXISTS test_dynamic_partition_failed_ok2 FORCE'
sql 'DROP TABLE IF EXISTS test_dynamic_partition_failed_2'
}
}

0 comments on commit 79b4154

Please sign in to comment.