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 @@ -97,8 +97,12 @@ public static DateLiteral getRangeEnd(DateLiteral beginTime, FunctionIntervalInf
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":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'))
(
)
Expand Down Expand Up @@ -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)
}