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 @@ -234,6 +234,13 @@ public void getTableRefs(Analyzer analyzer, List<TableRef> tblRefs, Set<String>
}
}

public void forbiddenMVRewrite() {
super.forbiddenMVRewrite();
for (SetOperand op : operands) {
op.getQueryStmt().forbiddenMVRewrite();
}
}

/**
* Propagates DISTINCT from left to right, and checks that all
* set operands are set compatible, adding implicit casts if necessary.
Expand Down
32 changes: 32 additions & 0 deletions regression-test/suites/mv_p0/test_base/test_base.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,36 @@ suite ("test_base") {
contains "(dwd)"
}
qt_select_mv "SELECT id,created_at FROM dwd order by 1, 2;"

sql """set enable_nereids_planner=false;"""
sql """drop table if exists test_mv_view_t;"""
sql """drop view if exists test_mv_view_t_view;"""
sql """CREATE TABLE `test_mv_view_t` (
`day` date NOT NULL,
`game_code` varchar(100) NOT NULL ,
`plat_code` varchar(100) NOT NULL
) ENGINE=OLAP
duplicate KEY(`day`)
DISTRIBUTED BY HASH(`day`) BUCKETS 4
PROPERTIES (
"replication_allocation" = "tag.location.default: 1"
);"""
sql """INSERT INTO test_mv_view_t VALUES('2024-04-01', 'x', 'y');"""
createMV ("""create materialized view test_mv_view_t_mv as
select `day`, count(game_code)
from test_mv_view_t group by day;""")
sql """create view test_mv_view_t_view
as
select `day`
from test_mv_view_t
where day<'2024-04-15'

union all
select `day`
from test_mv_view_t
where day>='2024-04-15';"""
explain {
sql("""SELECT * from test_mv_view_t_view where day='2024-04-15';""")
notContains("mv_day")
}
}