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 52bcbb71ab83c9..5acc45580adb99 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 @@ -465,6 +465,9 @@ private List checkAndPrepareMaterializedView(CreateMaterializedViewStmt 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 @@ -620,6 +623,9 @@ public List checkAndPrepareMaterializedView(AddRollupClause addRollupCla 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 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 c5b5935406aae2..d4df410d75fb09 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 void testInvalidKeysType(@Injectable CreateMaterializedViewStmt createMat @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 void testDuplicateTable(@Injectable CreateMaterializedViewStmt createMate 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 00000000000000..99cc3ba227eab3 --- /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 6bc9d6c134d6b7..2e194b83efc4bb 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 "