Skip to content
Open
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 @@ -628,8 +628,8 @@ private List<Column> checkAndPrepareMaterializedView(CreateMaterializedViewComma
break;
}
}
if (allKeysMatch) {
throw new DdlException("MV same with base table is useless.");
if (allKeysMatch && createMvCommand.getWhereClauseItem() == null) {
throw new DdlException("MV same with base table without where clause is useless.");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,7 @@
\N
\N

-- !select_mv --
1 1 1 a
1 1 1 a

Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,15 @@ suite ("nereids_k123p") {
qt_select_mv """select k1,k2+k3 from d_table where k1 = 2 and k4 = "b" order by k1;"""

qt_select_mv_constant """select bitmap_empty() from d_table where true;"""

create_sync_mv(db, "d_table", "k1234","""select k1 as x1, k2 as x2, k3 as x3, k4 as x4 from d_table where k1 = 1;""")
mv_rewrite_success_without_check_chosen("select k1 as x1, k2 as x2, k3 as x3, k4 as x4 from d_table where k1 = 1;", "k1234")
qt_select_mv "select k1 as x1, k2 as x2, k3 as x3, k4 as x4 from d_table where k1 = 1 order by k1;"
test {
sql """
create materialized view kx1234 as select k1 as y1, k2 as y2, k3 as y3, k4 as y4 from d_table;
"""

exception "MV same with base table without where clause is useless"
}
}
Loading