Skip to content

Commit

Permalink
[enhance](mtmv)Disable mtmv list rollup (apache#38124)
Browse files Browse the repository at this point in the history
Prohibit creating materialized views on partitions where the base table
is a list partition
  • Loading branch information
zddr authored and wyxxxcat committed Aug 14, 2024
1 parent f0e37ad commit 8d099a0
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 396 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ public void analyze(MTMVPartitionInfo mvPartitionInfo) throws AnalysisException
"partitionColumnType should be date/datetime "
+ "when PartitionType is range and expr is date_trunc");
}
} else {
throw new AnalysisException("date_trunc only support range partition");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@
2 20380101 sh
5 20380102 bj

-- !mtmv_datetrunc --
1 20380101 bj
2 20380101 sh
5 20380102 bj

-- !select_base_table --
1 bj 20380101
2 sh 20380101
Expand Down
37 changes: 0 additions & 37 deletions regression-test/data/mtmv_p0/test_rollup_partition_mtmv.out
Original file line number Diff line number Diff line change
@@ -1,41 +1,4 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !date_list_month --
1 2020-01-01 2020-01-01
2 2020-01-02 2020-01-02
3 2020-02-01 2020-02-01

-- !date_list_month_partition_by_column --
2020-01-01 1 2020-01-01 2020-01-01
2020-01-01 2 2020-01-02 2020-01-02
2020-02-01 3 2020-02-01 2020-02-01

-- !date_list_month_level --
2020-01-01 1 2020-01-01 2020-01-01
2020-01-02 2 2020-01-02 2020-01-02
2020-02-01 3 2020-02-01 2020-02-01

-- !date_list_month_level_agg --
2020-01-01 1 1
2020-01-02 2 1
2020-02-01 3 1

-- !date_list_month_level_agg_multi --
2020-01-01 2020-01-01 1
2020-01-02 2020-01-02 1
2020-02-01 2020-02-01 1

-- !date_list_month_level_agg --
2020-01-01 1
2020-01-02 1
2020-02-01 1

-- !date_list_year_partition_by_column --

-- !string_list_month --
1 2020==01==01
2 2020==01==02
3 2020==02==01

-- !date_range_month --
1 2020-01-01 2020-01-01
2 2020-01-02 2020-01-02
Expand Down
12 changes: 6 additions & 6 deletions regression-test/suites/mtmv_p0/test_build_mtmv.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -500,12 +500,12 @@ suite("test_build_mtmv") {
sql """
DROP MATERIALIZED VIEW ${mvName}
"""
def jobs = sql """select count(1) from jobs("type"="mv") where name= '${jobName}'"""
println jobs
assertEquals(jobs.get(0).get(0), 0);
def tasks = sql """select count(1) from tasks("type"="mv") where jobname = '${jobName}'"""
println tasks
assertEquals(tasks.get(0).get(0), 0);
def jobs = sql """select * from jobs("type"="mv") where MvName= '${mvName}'"""
log.info(jobs.toString())
assertEquals(0, jobs.size());
def tasks = sql """select * from tasks("type"="mv") where MvName = '${mvName}'"""
log.info(tasks.toString())
assertEquals(0, tasks.size());

// test bitmap
sql """drop table if exists `${tableName}`"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,34 +115,23 @@ suite("test_hive_limit_partition_mtmv", "p0,external,hive,external_docker,extern

// date trunc
sql """drop materialized view if exists ${mvName};"""
sql """
CREATE MATERIALIZED VIEW ${mvName}
BUILD DEFERRED REFRESH AUTO ON MANUAL
partition by (date_trunc(`day`,'month'))
DISTRIBUTED BY RANDOM BUCKETS 2
PROPERTIES (
'replication_num' = '1',
'partition_sync_limit'='2',
'partition_sync_time_unit'='MONTH',
'partition_date_format'='%Y%m%d'
)
AS
SELECT k1,day,region FROM ${catalog_name}.${hive_database}.${hive_table};
"""
showPartitionsResult = sql """show partitions from ${mvName}"""
logger.info("showPartitionsResult: " + showPartitionsResult.toString())
assertEquals(1, showPartitionsResult.size())
assertTrue(showPartitionsResult.toString().contains("_20380101"))
assertTrue(showPartitionsResult.toString().contains("_20380102"))

// refresh complete
sql """
REFRESH MATERIALIZED VIEW ${mvName} complete
"""
jobName = getJobName(dbName, mvName);
waitingMTMVTaskFinished(jobName)
order_qt_mtmv_datetrunc "SELECT * FROM ${mvName} order by k1,day,region"

test {
sql """
CREATE MATERIALIZED VIEW ${mvName}
BUILD DEFERRED REFRESH AUTO ON MANUAL
partition by (date_trunc(`day`,'month'))
DISTRIBUTED BY RANDOM BUCKETS 2
PROPERTIES (
'replication_num' = '1',
'partition_sync_limit'='2',
'partition_sync_time_unit'='MONTH',
'partition_date_format'='%Y%m%d'
)
AS
SELECT k1,day,region FROM ${catalog_name}.${hive_database}.${hive_table};
"""
exception "only support"
}

// date type
sql """drop materialized view if exists ${mvName};"""
Expand Down
Loading

0 comments on commit 8d099a0

Please sign in to comment.