Skip to content

Commit

Permalink
[Chore](materialized-view) forbid create mv on row store table (apach…
Browse files Browse the repository at this point in the history
…e#35360)

forbid create mv on row store table
  • Loading branch information
BiteTheDDDDt authored and eldenmoon committed Jan 15, 2025
1 parent fdff4a6 commit 9cb51da
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,9 @@ private List<Column> 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
Expand Down Expand Up @@ -620,6 +623,9 @@ public List<Column> 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<String> rollupColumnNames = addRollupClause.getColumnNames();
if (changeStorageFormat) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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();
Expand Down
32 changes: 32 additions & 0 deletions regression-test/suites/mv_p0/test_row_store/test_row_store.groovy
Original file line number Diff line number Diff line change
@@ -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"
}
}
5 changes: 0 additions & 5 deletions regression-test/suites/point_query_p0/load.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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 "

Expand Down

0 comments on commit 9cb51da

Please sign in to comment.