You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by st...@apache.org on 2025/11/20 07:30:19 UTC

(doris) branch master updated: [fix](nereids)where clause should only contains key column when create mv on unique table (#57915)

This is an automated email from the ASF dual-hosted git repository.

starocean999 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new dd4ec3375d0 [fix](nereids)where clause should only contains key column when create mv on unique table (#57915)
dd4ec3375d0 is described below

commit dd4ec3375d0c70a2e628b8f1c8965f48ffdb04d8
Author: starocean999 <li...@selectdb.com>
AuthorDate: Thu Nov 20 15:30:11 2025 +0800

    [fix](nereids)where clause should only contains key column when create mv on unique table (#57915)
---
 .../plans/commands/CreateMaterializedViewCommand.java    |  3 +--
 .../test_uniq_mv_useless/test_uniq_mv_useless.groovy     | 16 ++++++++++++++++
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/CreateMaterializedViewCommand.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/CreateMaterializedViewCommand.java
index a7f99e101ae..8ddd3a66e10 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/CreateMaterializedViewCommand.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/CreateMaterializedViewCommand.java
@@ -304,8 +304,7 @@ public class CreateMaterializedViewCommand extends Command implements ForwardWit
                         Column column = ((SlotReference) slot).getOriginalColumn().orElse(null);
                         if (column != null) {
                             if (column.isVisible()) {
-                                AggregateType aggregateType = column.getAggregationType();
-                                if (aggregateType != null && aggregateType != AggregateType.NONE) {
+                                if (context.keysType.isAggregationFamily() && !column.isKey()) {
                                     throw new AnalysisException(String.format(
                                             "The where clause contained aggregate column is not supported, expr is %s",
                                             expr));
diff --git a/regression-test/suites/mv_p0/test_mv_useless/test_uniq_mv_useless/test_uniq_mv_useless.groovy b/regression-test/suites/mv_p0/test_mv_useless/test_uniq_mv_useless/test_uniq_mv_useless.groovy
index 9eb66ccb5c3..ea931e1ded3 100644
--- a/regression-test/suites/mv_p0/test_mv_useless/test_uniq_mv_useless/test_uniq_mv_useless.groovy
+++ b/regression-test/suites/mv_p0/test_mv_useless/test_uniq_mv_useless/test_uniq_mv_useless.groovy
@@ -48,4 +48,20 @@ suite ("test_uniq_mv_useless") {
 
     createMV ("create materialized view k1_k2_u21 as select k2 as a1,k1 as a2 from ${testTable};")
     sql "insert into ${testTable} select 4,4,4;"
+
+    sql """ DROP TABLE IF EXISTS test_uniq_mv_useless_mow_table; """
+    sql """
+            create table test_uniq_mv_useless_mow_table (
+                k1 int null,
+                k2 int null,
+                k3 int 
+            )
+            unique key (k1,k2)
+            distributed BY hash(k1) buckets 3
+            properties("replication_num" = "1", "enable_unique_key_merge_on_write" = "true");
+        """
+    test {
+        sql "create materialized view k1_k2_u12 as select k1 as a1,k2 as a2 from test_uniq_mv_useless_mow_table where k3 > 0;"
+        exception "The where clause contained aggregate column is not supported"
+    }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org