|
| 1 | +// Licensed to the Apache Software Foundation (ASF) under one |
| 2 | +// or more contributor license agreements. See the NOTICE file |
| 3 | +// distributed with this work for additional information |
| 4 | +// regarding copyright ownership. The ASF licenses this file |
| 5 | +// to you under the Apache License, Version 2.0 (the |
| 6 | +// "License"); you may not use this file except in compliance |
| 7 | +// with the License. You may obtain a copy of the License at |
| 8 | +// |
| 9 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +// |
| 11 | +// Unless required by applicable law or agreed to in writing, |
| 12 | +// software distributed under the License is distributed on an |
| 13 | +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | +// KIND, either express or implied. See the License for the |
| 15 | +// specific language governing permissions and limitations |
| 16 | +// under the License. |
| 17 | + |
| 18 | +suite("test_upgrade_downgrade_prepare_olap_mtmv","p0,mtmv,restart_fe") { |
| 19 | + String suiteName = "mtmv_up_down_olap" |
| 20 | + String mvName = "${suiteName}_mtmv" |
| 21 | + String tableName = "${suiteName}_table" |
| 22 | + String tableName2 = "${suiteName}_table2" |
| 23 | + |
| 24 | + sql """drop materialized view if exists ${mvName};""" |
| 25 | + sql """drop table if exists `${tableName}`""" |
| 26 | + sql """drop table if exists `${tableName2}`""" |
| 27 | + |
| 28 | + sql """ |
| 29 | + CREATE TABLE `${tableName}` ( |
| 30 | + `user_id` LARGEINT NOT NULL COMMENT '\"用户id\"', |
| 31 | + `date` DATE NOT NULL COMMENT '\"数据灌入日期时间\"', |
| 32 | + `num` SMALLINT NOT NULL COMMENT '\"数量\"' |
| 33 | + ) ENGINE=OLAP |
| 34 | + DUPLICATE KEY(`user_id`, `date`, `num`) |
| 35 | + COMMENT 'OLAP' |
| 36 | + PARTITION BY RANGE(`date`) |
| 37 | + (PARTITION p201701_1000 VALUES [('0000-01-01'), ('2017-02-01')), |
| 38 | + PARTITION p201702_2000 VALUES [('2017-02-01'), ('2017-03-01')), |
| 39 | + PARTITION p201703_all VALUES [('2017-03-01'), ('2017-04-01'))) |
| 40 | + DISTRIBUTED BY HASH(`user_id`) BUCKETS 2 |
| 41 | + PROPERTIES ('replication_num' = '1') ; |
| 42 | + """ |
| 43 | + sql """ |
| 44 | + insert into ${tableName} values(1,"2017-01-15",1),(2,"2017-02-15",2),(3,"2017-03-15",3); |
| 45 | + """ |
| 46 | + |
| 47 | + sql """ |
| 48 | + CREATE TABLE `${tableName2}` ( |
| 49 | + `user_id` LARGEINT NOT NULL COMMENT '\"用户id\"', |
| 50 | + `age` SMALLINT NOT NULL COMMENT '\"年龄\"' |
| 51 | + ) ENGINE=OLAP |
| 52 | + DUPLICATE KEY(`user_id`, `age`) |
| 53 | + COMMENT 'OLAP' |
| 54 | + DISTRIBUTED BY HASH(`user_id`) BUCKETS 2 |
| 55 | + PROPERTIES ('replication_num' = '1') ; |
| 56 | + """ |
| 57 | + sql """ |
| 58 | + insert into ${tableName2} values(1,1),(2,2),(3,3); |
| 59 | + """ |
| 60 | + |
| 61 | + sql """ |
| 62 | + CREATE MATERIALIZED VIEW ${mvName} |
| 63 | + REFRESH AUTO ON MANUAL |
| 64 | + partition by(`date`) |
| 65 | + DISTRIBUTED BY RANDOM BUCKETS 2 |
| 66 | + PROPERTIES ('replication_num' = '1') |
| 67 | + AS |
| 68 | + SELECT a.* FROM ${tableName} a inner join ${tableName2} b on a.user_id=b.user_id; |
| 69 | + """ |
| 70 | + waitingMTMVTaskFinishedByMvName(mvName) |
| 71 | +} |
0 commit comments