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 82ff29faeae9eb0cfebc98d0432df306a550d5d9
Author: Pxl <pxl...@qq.com>
AuthorDate: Mon May 27 10:50:57 2024 +0800

    [Chore](materialized-view) forbid create mv on row store table (#35360)
    
    forbid create mv on row store table
---
 .../doris/alter/MaterializedViewHandler.java       |  6 ++++
 .../doris/alter/MaterializedViewHandlerTest.java   |  6 ++--
 .../mv_p0/test_row_store/test_row_store.groovy     | 32 ++++++++++++++++++++++
 regression-test/suites/point_query_p0/load.groovy  | 25 -----------------
 4 files changed, 42 insertions(+), 27 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 a6b6c709dd5..a6a132e316c 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
@@ -473,6 +473,9 @@ public class MaterializedViewHandler extends AlterHandler {
         if (olapTable.getEnableUniqueKeyMergeOnWrite()) {
             throw new DdlException("MergeOnWrite table can't create 
materialized view.");
         }
+        if (olapTable.getRowStoreCol() != null) {
+            throw new DdlException("RowStore table can't create materialized 
view.");
+        }
         // check if mv columns are valid
         // a. Aggregate table:
         // 1. all slot's aggregationType must same with value mv column
@@ -630,6 +633,9 @@ public class MaterializedViewHandler extends AlterHandler {
         if (olapTable.getEnableUniqueKeyMergeOnWrite()) {
             throw new DdlException("MergeOnWrite table can't create 
materialized view.");
         }
+        if (olapTable.getRowStoreCol() != null) {
+            throw new DdlException("RowStore table can't create materialized 
view.");
+        }
         String rollupIndexName = addRollupClause.getRollupName();
         List<String> rollupColumnNames = addRollupClause.getColumnNames();
         if (changeStorageFormat) {
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/alter/MaterializedViewHandlerTest.java
 
b/fe/fe-core/src/test/java/org/apache/doris/alter/MaterializedViewHandlerTest.java
index c5b5935406a..d4df410d75f 100644
--- 
a/fe/fe-core/src/test/java/org/apache/doris/alter/MaterializedViewHandlerTest.java
+++ 
b/fe/fe-core/src/test/java/org/apache/doris/alter/MaterializedViewHandlerTest.java
@@ -181,8 +181,8 @@ public class MaterializedViewHandlerTest {
                                     @Injectable OlapTable olapTable) {
         new Expectations() {
             {
-                createMaterializedViewStmt.getMVKeysType();
-                result = KeysType.DUP_KEYS;
+                olapTable.getRowStoreCol();
+                result = null;
                 olapTable.getKeysType();
                 result = KeysType.AGG_KEYS;
             }
@@ -228,6 +228,8 @@ public class MaterializedViewHandlerTest {
                 result = list;
                 olapTable.getKeysType();
                 result = KeysType.DUP_KEYS;
+                olapTable.getRowStoreCol();
+                result = null;
             }
         };
         MaterializedViewHandler materializedViewHandler = new 
MaterializedViewHandler();
diff --git a/regression-test/suites/mv_p0/test_row_store/test_row_store.groovy 
b/regression-test/suites/mv_p0/test_row_store/test_row_store.groovy
new file mode 100644
index 00000000000..99cc3ba227e
--- /dev/null
+++ b/regression-test/suites/mv_p0/test_row_store/test_row_store.groovy
@@ -0,0 +1,32 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+import org.codehaus.groovy.runtime.IOGroovyMethods
+
+suite ("test_row_store") {
+
+    sql """ DROP TABLE IF EXISTS d_table; """
+
+    sql """
+            create table d_table ( k1 int null, k2 int not null, k3 bigint 
null,     k4 varchar(100) null ) duplicate key (k1,k2,k3) distributed BY 
hash(k1) buckets 3 properties("replication_num" = "1","store_row_column" = 
"true");
+        """
+
+    test {
+        sql "create materialized view kavg as select k1,k4,avg(k2) from 
d_table group by k1,k4;"
+        exception "RowStore table can't create materialized view"
+    }
+}
diff --git a/regression-test/suites/point_query_p0/load.groovy 
b/regression-test/suites/point_query_p0/load.groovy
index b5610965aeb..2e194b83efc 100644
--- a/regression-test/suites/point_query_p0/load.groovy
+++ b/regression-test/suites/point_query_p0/load.groovy
@@ -67,13 +67,8 @@ suite("test_point_query_load", "p0") {
             assertEquals(100000, json.NumberLoadedRows)
         }
     }
-    createMV ("""CREATE MATERIALIZED VIEW mv_${testTable} AS SELECT c_tinyint, 
c_bool, k1, c_smallint, c_int, c_bigint, c_largeint, c_float, c_double,  
c_decimal, c_decimalv3, c_date, c_datetime, c_datev2, c_datetimev2, c_char, 
c_varchar, c_string FROM ${testTable} ORDER BY c_tinyint, c_bool, k1""")
 
     sql "set topn_opt_limit_threshold = 100"
-    explain {
-        sql("SELECT * from ${testTable} where c_tinyint = 10 order by 1, 2, 3 
limit 10")
-        contains "(mv_${testTable})"
-    }
     qt_sql "SELECT * from ${testTable} order by 1, 2, 3 limit 10"
     qt_sql "SELECT * from ${testTable} where c_tinyint = 10 order by 1, 2, 3 
limit 10 "
 
@@ -97,24 +92,4 @@ suite("test_point_query_load", "p0") {
           }
      }
     sql "INSERT INTO ${testTable} SELECT * from ${testTable}"
-
-    // test nereids planner
-    sql """set enable_nereids_planner=true;"""
-    explain {
-        sql("""SELECT
-                    t0.`c_int` as column_key,
-                    COUNT(1) as `count`
-                FROM
-                    (
-                        SELECT
-                            `c_int`
-                        FROM
-                            `tbl_scalar_types_dup`
-                        limit
-                            200000
-                    ) as `t0`
-                GROUP BY
-                    `t0`.`c_int`""")
-        notContains "(mv_${testTable})"
-    }
 }


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

Reply via email to