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

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


The following commit(s) were added to refs/heads/branch-2.0 by this push:
     new 68f27187f77 [Bug](materialized-view) forbid create mv with value 
column before key column #33436 (#33844)
68f27187f77 is described below

commit 68f27187f774a5b17580343176c3cc0df5c7a5bf
Author: Pxl <pxl...@qq.com>
AuthorDate: Thu Apr 18 19:14:30 2024 +0800

    [Bug](materialized-view) forbid create mv with value column before key 
column #33436 (#33844)
    
    forbid create mv with value column before key column
---
 fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java | 6 ++++++
 regression-test/suites/mv_p0/unique/unique.groovy          | 6 ++++++
 2 files changed, 12 insertions(+)

diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java 
b/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java
index c0d6f0c3a07..a169309848c 100755
--- a/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java
@@ -3914,9 +3914,15 @@ public class Env {
     public static short calcShortKeyColumnCount(List<Column> columns, 
Map<String, String> properties,
                                                 boolean isKeysRequired) throws 
DdlException {
         List<Column> indexColumns = new ArrayList<Column>();
+        boolean hasValueColumn = false;
         for (Column column : columns) {
             if (column.isKey()) {
+                if (hasValueColumn && isKeysRequired) {
+                    throw new DdlException("The materialized view not support 
value column before key column");
+                }
                 indexColumns.add(column);
+            } else {
+                hasValueColumn = true;
             }
         }
         LOG.debug("index column size: {}", indexColumns.size());
diff --git a/regression-test/suites/mv_p0/unique/unique.groovy 
b/regression-test/suites/mv_p0/unique/unique.groovy
index 473c078529e..ec5461188f9 100644
--- a/regression-test/suites/mv_p0/unique/unique.groovy
+++ b/regression-test/suites/mv_p0/unique/unique.groovy
@@ -40,11 +40,17 @@ suite ("unique") {
         sql """create materialized view k12s3m as select k1,sum(k2),max(k2) 
from u_table group by k1;"""
         exception "must not has grouping columns"
     }
+
     test {
         sql """create materialized view kadj as select k4 from u_table"""
         exception "The materialized view need key column"
     }
 
+    test {
+        sql """create materialized view kadj as select k4,k1 from u_table"""
+        exception "The materialized view not support value column before key 
column"
+    }
+
     createMV("create materialized view kadj as select k3,k2,k1,k4 from 
u_table;")
 
     createMV("create materialized view kadj2 as select k3,k2,length(k4) from 
u_table;")


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

Reply via email to