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

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

commit ab4f8fafcde40bbaf3a79d1aae3c69b439296681
Author: Pxl <[email protected]>
AuthorDate: Wed Apr 10 15:17:23 2024 +0800

    [Bug](materialized-view) forbid create mv with value column before key 
column (#33436)
    
    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 69906597b79..08a068f44c1 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
@@ -4169,9 +4169,15 @@ public class Env {
                                                 boolean isKeysRequired) throws 
DdlException {
         List<Column> indexColumns = new ArrayList<Column>();
         Map<Integer, Column> clusterColumns = new TreeMap<>();
+        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;
             }
             if (column.isClusterKey()) {
                 clusterColumns.put(column.getClusterKeyId(), column);
diff --git a/regression-test/suites/mv_p0/unique/unique.groovy 
b/regression-test/suites/mv_p0/unique/unique.groovy
index 1cb79e7becc..c5c7e95d890 100644
--- a/regression-test/suites/mv_p0/unique/unique.groovy
+++ b/regression-test/suites/mv_p0/unique/unique.groovy
@@ -41,11 +41,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: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to