zddr commented on code in PR #35562: URL: https://github.com/apache/doris/pull/35562#discussion_r1625779670
########## regression-test/suites/mtmv_p0/test_rollup_partition_mtmv.groovy: ########## @@ -257,6 +374,65 @@ suite("test_rollup_partition_mtmv") { waitingMTMVTaskFinished(jobName) order_qt_date_range_month_partition_by_column "SELECT * FROM ${mvName}" + sql """drop materialized view if exists ${mvName};""" + sql """ + CREATE MATERIALIZED VIEW ${mvName} + BUILD IMMEDIATE REFRESH AUTO ON MANUAL + partition by (date_trunc(month_alias, 'month')) + DISTRIBUTED BY RANDOM BUCKETS 2 + PROPERTIES ( + 'replication_num' = '1' + ) + AS + SELECT date_trunc(`k2`,'day') as month_alias FROM ${tableName}; + """ + def date_range_month_partitions_level = sql """show partitions from ${mvName}""" + logger.info("showPartitionsResult: " + date_range_month_partitions_level.toString()) + assertEquals(2, date_range_month_partitions_level.size()) + waitingMTMVTaskFinished(getJobName(dbName, mvName)) + order_qt_date_range_month_level "SELECT * FROM ${mvName}" + + // mv partition level should be higher or equal then query, should fail + sql """drop materialized view if exists ${mvName};""" + try { + sql """ + CREATE MATERIALIZED VIEW ${mvName} + BUILD IMMEDIATE REFRESH AUTO ON MANUAL + partition by (date_trunc(month_alias, 'day')) + DISTRIBUTED BY RANDOM BUCKETS 2 + PROPERTIES ( + 'replication_num' = '1' + ) + AS + SELECT date_trunc(`k2`,'month') as month_alias, * FROM ${tableName}; + """ + Assert.fail(); + } catch (Exception e) { + log.info(e.getMessage()) + assertTrue(e.getMessage().contains("partition column time unit level should be greater than sql select column")) + } + + // mv partition use a column not in mv sql select, should fail + sql """drop materialized view if exists ${mvName};""" + try { + sql """ + CREATE MATERIALIZED VIEW ${mvName} + BUILD IMMEDIATE REFRESH AUTO ON MANUAL + partition by (date_trunc(`k2`, 'month')) + DISTRIBUTED BY RANDOM BUCKETS 2 + PROPERTIES ( + 'replication_num' = '1' + ) + AS + SELECT date_trunc(`k2`,'day') as month_alias FROM ${tableName}; Review Comment: month_alias==>day_alias? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org