This is an automated email from the ASF dual-hosted git repository. panxiaolei pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push: new fd8ed80fd66 [Enhancement](auto-partition) support all intervals for date_trunc in auto partition (#33439) fd8ed80fd66 is described below commit fd8ed80fd66a1d8d5ce1fb9933b059c77c43c61e Author: zclllyybb <zhaochan...@selectdb.com> AuthorDate: Wed Apr 10 15:28:26 2024 +0800 [Enhancement](auto-partition) support all intervals for date_trunc in auto partition (#33439) support all intervals for date_trunc in auto partition --- .../apache/doris/analysis/PartitionExprUtil.java | 4 +++ .../test_auto_range_partition.groovy | 41 ++++++++++++++++++++-- 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/PartitionExprUtil.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/PartitionExprUtil.java index 2869097555b..420bee53e18 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/PartitionExprUtil.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/PartitionExprUtil.java @@ -97,8 +97,12 @@ public class PartitionExprUtil { switch (timeUnit) { case "year": return beginTime.plusYears(interval); + case "quarter": + return beginTime.plusMonths(interval * 3); case "month": return beginTime.plusMonths(interval); + case "week": + return beginTime.plusDays(interval * 7); case "day": return beginTime.plusDays(interval); case "hour": diff --git a/regression-test/suites/partition_p0/auto_partition/test_auto_range_partition.groovy b/regression-test/suites/partition_p0/auto_partition/test_auto_range_partition.groovy index 52325690ce7..e0f8db3ac8f 100644 --- a/regression-test/suites/partition_p0/auto_partition/test_auto_range_partition.groovy +++ b/regression-test/suites/partition_p0/auto_partition/test_auto_range_partition.groovy @@ -20,9 +20,8 @@ suite("test_auto_range_partition") { sql """ CREATE TABLE `range_table1` ( `TIME_STAMP` datetimev2 NOT NULL COMMENT '采集日期' - ) ENGINE=OLAP + ) DUPLICATE KEY(`TIME_STAMP`) - COMMENT 'OLAP' auto partition by range (date_trunc(`TIME_STAMP`, 'day')) ( ) @@ -102,4 +101,42 @@ suite("test_auto_range_partition") { result2 = sql "show partitions from right_bound" logger.info("${result2}") assertEquals(result2.size(), 2) + + sql "drop table if exists week_range" + sql """ + CREATE TABLE `week_range` ( + `TIME_STAMP` datev2 NOT NULL + ) + DUPLICATE KEY(`TIME_STAMP`) + auto partition by range (date_trunc(`TIME_STAMP`, 'week')) + ( + ) + DISTRIBUTED BY HASH(`TIME_STAMP`) BUCKETS 10 + PROPERTIES ( + "replication_allocation" = "tag.location.default: 1" + ); + """ + sql " insert into week_range values (20240408), (20240409); " + result2 = sql "show partitions from week_range" + logger.info("${result2}") + assertEquals(result2.size(), 1) + + sql "drop table if exists quarter_range" + sql """ + CREATE TABLE `quarter_range` ( + `TIME_STAMP` datev2 NOT NULL + ) + DUPLICATE KEY(`TIME_STAMP`) + auto partition by range (date_trunc(`TIME_STAMP`, 'quarter')) + ( + ) + DISTRIBUTED BY HASH(`TIME_STAMP`) BUCKETS 10 + PROPERTIES ( + "replication_allocation" = "tag.location.default: 1" + ); + """ + sql " insert into quarter_range values (20240102), (20240330), (20241001), (20241231); " + result2 = sql "show partitions from quarter_range" + logger.info("${result2}") + assertEquals(result2.size(), 2) } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org