[fix](mtmv)Mtmv support row column (#35860) (#35956)

pick from master: #35860
This commit is contained in:
zhangdong
2024-06-06 22:53:08 +08:00
committed by GitHub
parent fbc82e0253
commit 9efc7b63ec
3 changed files with 98 additions and 0 deletions

View File

@ -34,6 +34,7 @@ import org.apache.doris.catalog.View;
import org.apache.doris.common.ErrorCode;
import org.apache.doris.common.FeNameFormat;
import org.apache.doris.common.util.DynamicPartitionUtil;
import org.apache.doris.common.util.PropertyAnalyzer;
import org.apache.doris.mtmv.EnvInfo;
import org.apache.doris.mtmv.MTMVPartitionInfo;
import org.apache.doris.mtmv.MTMVPartitionInfo.MTMVPartitionType;
@ -335,6 +336,18 @@ public class CreateMTMVInfo {
CollectionUtils.isEmpty(simpleColumnDefinitions) ? null
: simpleColumnDefinitions.get(i).getComment()));
}
// add a hidden column as row store
if (properties != null) {
try {
boolean storeRowColumn =
PropertyAnalyzer.analyzeStoreRowColumn(Maps.newHashMap(properties));
if (storeRowColumn) {
columns.add(ColumnDefinition.newRowStoreColumnDefinition(null));
}
} catch (Exception e) {
throw new AnalysisException(e.getMessage(), e.getCause());
}
}
}
/**

View File

@ -0,0 +1,13 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !k1 --
1 1
-- !k2 --
3 3
-- !k1_k2 --
1 1
-- !k2_k1 --
1 1

View File

@ -0,0 +1,72 @@
// 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.junit.Assert;
suite("test_row_column_mtmv","mtmv") {
String suiteName = "test_row_column_mtmv"
String tableName = "${suiteName}_table"
String mvName = "${suiteName}_mv"
sql """drop table if exists `${tableName}`"""
sql """drop materialized view if exists ${mvName};"""
sql """
CREATE TABLE ${tableName}
(
k1 TINYINT,
k2 INT not null
)
COMMENT "my first table"
DISTRIBUTED BY HASH(k2) BUCKETS 2
PROPERTIES (
"replication_num" = "1"
);
"""
sql """
insert into ${tableName} values(1,1),(2,2),(3,3);
"""
sql """
CREATE MATERIALIZED VIEW ${mvName}
BUILD DEFERRED REFRESH AUTO ON MANUAL
DISTRIBUTED BY RANDOM BUCKETS 2
PROPERTIES (
'replication_num' = '1',
'store_row_column' = 'true'
)
AS
SELECT * from ${tableName};
"""
sql """
REFRESH MATERIALIZED VIEW ${mvName} AUTO
"""
waitingMTMVTaskFinishedByMvName(mvName)
order_qt_k1 "SELECT * FROM ${mvName} order by k1 limit 1"
order_qt_k2 "SELECT * FROM ${mvName} order by k2 desc limit 1"
order_qt_k1_k2 "SELECT * FROM ${mvName} order by k1,k2 limit 1"
order_qt_k2_k1 "SELECT * FROM ${mvName} order by k2,k1 limit 1"
sql """SET show_hidden_columns=true;"""
def colRes = sql """desc ${mvName};"""
logger.info("colRes: " + colRes.toString())
assertTrue(colRes.toString().contains("__DORIS_ROW_STORE_COL__"))
sql """SET show_hidden_columns=false;"""
sql """drop table if exists `${tableName}`"""
sql """drop materialized view if exists ${mvName};"""
}