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 84396dbb39d068d62b1bdc94837ae01e891c3d81 Author: zhangdong <[email protected]> AuthorDate: Mon Apr 29 12:15:11 2024 +0800 [enhance](mtmv) When specifying a data model in a materialized view, it is compatible with the syntax of an OLAP table (#34231) --- .../antlr4/org/apache/doris/nereids/DorisParser.g4 | 2 +- .../suites/mtmv_p0/test_key_mtmv.groovy | 61 ++++++++++++++++++++++ 2 files changed, 62 insertions(+), 1 deletion(-) diff --git a/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisParser.g4 b/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisParser.g4 index b26019aa3ef..764a5625185 100644 --- a/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisParser.g4 +++ b/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisParser.g4 @@ -96,7 +96,7 @@ statementBase | CREATE MATERIALIZED VIEW (IF NOT EXISTS)? mvName=multipartIdentifier (LEFT_PAREN cols=simpleColumnDefs RIGHT_PAREN)? buildMode? (REFRESH refreshMethod? refreshTrigger?)? - (KEY keys=identifierList)? + ((DUPLICATE)? KEY keys=identifierList)? (COMMENT STRING_LITERAL)? (PARTITION BY LEFT_PAREN partitionKey = identifier RIGHT_PAREN)? (DISTRIBUTED BY (HASH hashKeys=identifierList | RANDOM) (BUCKETS (INTEGER_VALUE | AUTO))?)? diff --git a/regression-test/suites/mtmv_p0/test_key_mtmv.groovy b/regression-test/suites/mtmv_p0/test_key_mtmv.groovy new file mode 100644 index 00000000000..ed403e1581f --- /dev/null +++ b/regression-test/suites/mtmv_p0/test_key_mtmv.groovy @@ -0,0 +1,61 @@ +// 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_key_mtmv") { + def tableName = "t_test_key_mtmv_user" + def mvName = "test_key_mtmv" + def dbName = "regression_test_mtmv_p0" + sql """drop table if exists `${tableName}`""" + sql """drop materialized view if exists ${mvName};""" + + sql """ + CREATE TABLE `${tableName}` ( + `user_id` LARGEINT NOT NULL COMMENT '\"用户id\"', + `num` SMALLINT NOT NULL COMMENT '\"数量\"' + ) ENGINE=OLAP + DUPLICATE KEY(`user_id`) + COMMENT 'OLAP' + DISTRIBUTED BY HASH(`user_id`) BUCKETS 2 + PROPERTIES ('replication_num' = '1') ; + """ + + sql """ + CREATE MATERIALIZED VIEW ${mvName} + BUILD DEFERRED REFRESH AUTO ON MANUAL + KEY(`user_id`) + DISTRIBUTED BY RANDOM BUCKETS 2 + PROPERTIES ('replication_num' = '1') + AS + SELECT * FROM ${tableName}; + """ + sql """drop materialized view if exists ${mvName};""" + + sql """ + CREATE MATERIALIZED VIEW ${mvName} + BUILD DEFERRED REFRESH AUTO ON MANUAL + DUPLICATE KEY(`user_id`) + DISTRIBUTED BY RANDOM BUCKETS 2 + PROPERTIES ('replication_num' = '1') + AS + SELECT * FROM ${tableName}; + """ + + sql """drop table if exists `${tableName}`""" + sql """drop materialized view if exists ${mvName};""" +} --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
