This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.1 by this push:
new 319933d0a64 [enhance](mtmv)mtmv date trunc support hour (#37678)
(#38422)
319933d0a64 is described below
commit 319933d0a64c2123d5cc26ceaffc4f66b2d6221a
Author: zhangdong <[email protected]>
AuthorDate: Wed Jul 31 10:46:08 2024 +0800
[enhance](mtmv)mtmv date trunc support hour (#37678) (#38422)
pick: https://github.com/apache/doris/pull/37678
---
.../doris/mtmv/MTMVPartitionExprDateTrunc.java | 5 ++-
.../mtmv_p0/test_rollup_partition_mtmv.groovy | 39 ++++++++++++++++------
2 files changed, 32 insertions(+), 12 deletions(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVPartitionExprDateTrunc.java
b/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVPartitionExprDateTrunc.java
index a42fae22585..f16252cede0 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVPartitionExprDateTrunc.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVPartitionExprDateTrunc.java
@@ -47,7 +47,7 @@ import java.util.Optional;
import java.util.Set;
public class MTMVPartitionExprDateTrunc implements MTMVPartitionExprService {
- private static Set<String> timeUnits = ImmutableSet.of("year", "month",
"day");
+ private static Set<String> timeUnits = ImmutableSet.of("year", "month",
"day", "hour");
private String timeUnit;
public MTMVPartitionExprDateTrunc(FunctionCallExpr functionCallExpr)
throws AnalysisException {
@@ -202,6 +202,9 @@ public class MTMVPartitionExprDateTrunc implements
MTMVPartitionExprService {
case "day":
result = value.plusDays(1L);
break;
+ case "hour":
+ result = value.plusHours(1L);
+ break;
default:
throw new AnalysisException(
"async materialized view partition roll up not support
timeUnit: " + timeUnit);
diff --git a/regression-test/suites/mtmv_p0/test_rollup_partition_mtmv.groovy
b/regression-test/suites/mtmv_p0/test_rollup_partition_mtmv.groovy
index c24bc5aa910..21c77bc1e24 100644
--- a/regression-test/suites/mtmv_p0/test_rollup_partition_mtmv.groovy
+++ b/regression-test/suites/mtmv_p0/test_rollup_partition_mtmv.groovy
@@ -661,21 +661,21 @@ suite("test_rollup_partition_mtmv") {
log.info(e.getMessage())
}
- // not support trunc hour
+ // not support trunc minute
sql """drop table if exists `${tableName}`"""
sql """drop materialized view if exists ${mvName};"""
sql """
CREATE TABLE `${tableName}` (
`k1` LARGEINT NOT NULL COMMENT '\"用户id\"',
- `k2` DATE NOT NULL COMMENT '\"数据灌入日期时间\"'
+ `k2` DATETIME NOT NULL COMMENT '\"数据灌入日期时间\"'
) ENGINE=OLAP
DUPLICATE KEY(`k1`)
COMMENT 'OLAP'
PARTITION BY range(`k2`)
(
- PARTITION p_20200101 VALUES [("2020-01-01"),("2020-01-02")),
- PARTITION p_20200102 VALUES [("2020-01-02"),("2020-01-03")),
- PARTITION p_20200201 VALUES [("2020-02-01"),("2020-02-02"))
+ PARTITION p_1 VALUES [("2020-01-01 00:00:00"),("2020-01-01 00:30:00")),
+ PARTITION p_2 VALUES [("2020-01-01 00:30:00"),("2020-01-01 01:00:00")),
+ PARTITION p_3 VALUES [("2020-01-01 01:00:00"),("2020-01-01 01:30:00"))
)
DISTRIBUTED BY HASH(`k1`) BUCKETS 2
PROPERTIES ('replication_num' = '1') ;
@@ -685,7 +685,7 @@ suite("test_rollup_partition_mtmv") {
sql """
CREATE MATERIALIZED VIEW ${mvName}
BUILD DEFERRED REFRESH AUTO ON MANUAL
- partition by (date_trunc(`k2`,'hour'))
+ partition by (date_trunc(`k2`,'minute'))
DISTRIBUTED BY RANDOM BUCKETS 2
PROPERTIES (
'replication_num' = '1'
@@ -698,23 +698,40 @@ suite("test_rollup_partition_mtmv") {
log.info(e.getMessage())
}
+ // support hour
+ sql """
+ CREATE MATERIALIZED VIEW ${mvName}
+ BUILD DEFERRED REFRESH AUTO ON MANUAL
+ partition by (date_trunc(`k2`,'hour'))
+ DISTRIBUTED BY RANDOM BUCKETS 2
+ PROPERTIES (
+ 'replication_num' = '1'
+ )
+ AS
+ SELECT * FROM ${tableName};
+ """
+
+ def hour_partitions = sql """show partitions from ${mvName}"""
+ logger.info("hour_partitions: " + hour_partitions.toString())
+ assertEquals(2, hour_partitions.size())
+
sql """drop materialized view if exists ${mvName};"""
try {
sql """
CREATE MATERIALIZED VIEW ${mvName}
BUILD DEFERRED REFRESH AUTO ON MANUAL
- partition by (hour_alias)
+ partition by (minute_alias)
DISTRIBUTED BY RANDOM BUCKETS 2
PROPERTIES (
'replication_num' = '1'
)
AS
- SELECT date_trunc(`k2`,'hour') as hour_alias, * FROM
${tableName};
+ SELECT date_trunc(`k2`,'minute') as minute_alias, * FROM
${tableName};
"""
Assert.fail();
} catch (Exception e) {
log.info(e.getMessage())
- assertTrue(e.getMessage().contains("timeUnit not support: hour"))
+ assertTrue(e.getMessage().contains("timeUnit not support: minute"))
}
sql """drop materialized view if exists ${mvName};"""
@@ -722,7 +739,7 @@ suite("test_rollup_partition_mtmv") {
sql """
CREATE MATERIALIZED VIEW ${mvName}
BUILD IMMEDIATE REFRESH AUTO ON MANUAL
- partition by (date_trunc(minute_alias, 'hour'))
+ partition by (date_trunc(minute_alias, 'minute'))
DISTRIBUTED BY RANDOM BUCKETS 2
PROPERTIES (
'replication_num' = '1'
@@ -733,6 +750,6 @@ suite("test_rollup_partition_mtmv") {
Assert.fail();
} catch (Exception e) {
log.info(e.getMessage())
- assertTrue(e.getMessage().contains("timeUnit not support: hour"))
+ assertTrue(e.getMessage().contains("timeUnit not support: minute"))
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]