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

yiguolei pushed a commit to branch branch-4.0
in repository https://gitbox.apache.org/repos/asf/doris.git


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

commit b0b7b2a8ab8d5dd8e5a9da27dea851b7112eacd9
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Fri Nov 21 09:02:01 2025 +0800

    branch-4.0: [fix](nereids)where clause should only contains key column when 
create mv on unique table #57915 (#58179)
    
    Cherry-picked from #57915
    
    Co-authored-by: starocean999 <[email protected]>
---
 .../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 2ad3291681d..be6b8bf8455 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: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to