This is an automated email from the ASF dual-hosted git repository.
morrysnow pushed a commit to branch branch-3.1
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-3.1 by this push:
new b604f8e24e1 branch-3.1: [fix](nereids)allow sync mv has same columns
as base table when it has where clause #58105 (#58342)
b604f8e24e1 is described below
commit b604f8e24e1429d59bd0fc4be9fbbbe19284ead4
Author: starocean999 <[email protected]>
AuthorDate: Wed Nov 26 10:44:59 2025 +0800
branch-3.1: [fix](nereids)allow sync mv has same columns as base table when
it has where clause #58105 (#58342)
picked from #58105
---
.../org/apache/doris/alter/MaterializedViewHandler.java | 4 ++--
regression-test/data/mv_p0/where/k123/k123.out | 4 ++++
regression-test/suites/mv_p0/where/k123/k123.groovy | 13 +++++++++++++
3 files changed, 19 insertions(+), 2 deletions(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/alter/MaterializedViewHandler.java
b/fe/fe-core/src/main/java/org/apache/doris/alter/MaterializedViewHandler.java
index 9145622871f..16bfb463e17 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/alter/MaterializedViewHandler.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/alter/MaterializedViewHandler.java
@@ -624,8 +624,8 @@ public class MaterializedViewHandler extends AlterHandler {
break;
}
}
- if (allKeysMatch) {
- throw new DdlException("MV same with base table is useless.");
+ if (allKeysMatch && addMVClause.getWhereClause() == null) {
+ throw new DdlException("MV same with base table without where
clause is useless.");
}
}
diff --git a/regression-test/data/mv_p0/where/k123/k123.out
b/regression-test/data/mv_p0/where/k123/k123.out
index faeb23fbb62..ec7d079caf4 100644
--- a/regression-test/data/mv_p0/where/k123/k123.out
+++ b/regression-test/data/mv_p0/where/k123/k123.out
@@ -47,3 +47,7 @@
\N
\N
+-- !select_mv --
+1 1 1 a
+1 1 1 a
+
diff --git a/regression-test/suites/mv_p0/where/k123/k123.groovy
b/regression-test/suites/mv_p0/where/k123/k123.groovy
index 3527a889f83..4d470c8434c 100644
--- a/regression-test/suites/mv_p0/where/k123/k123.groovy
+++ b/regression-test/suites/mv_p0/where/k123/k123.groovy
@@ -110,4 +110,17 @@ suite ("k123p") {
}
createMV ("""create materialized view k123p1w as select k1 as a1,k2 as
a2,k3 as a3 from u_table where k1 = 1;""")
+
+ String db = context.config.getDbNameByFile(context.file)
+ sql "use ${db}"
+ 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"
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]