[Chore](materialized-view) forbid create mv on row store table (#35360)

forbid create mv on row store table
This commit is contained in:
Pxl
2024-05-27 10:50:57 +08:00
committed by yiguolei
parent 7284b6959f
commit 82ff29faea
4 changed files with 42 additions and 27 deletions

View File

@ -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) {

View File

@ -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();

View File

@ -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"
}
}

View File

@ -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})"
}
}