|
| 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 | +import java.util.concurrent.TimeUnit |
| 19 | +import org.awaitility.Awaitility |
| 20 | + |
| 21 | +suite("test_schema_change_with_empty_rowset", "p0,nonConcurrent") { |
| 22 | + def custoBeConfig = [ |
| 23 | + max_tablet_version_num : 100 |
| 24 | + ] |
| 25 | + |
| 26 | + setBeConfigTemporary(custoBeConfig) { |
| 27 | + def tableName = "test_sc_with_empty_rowset" |
| 28 | + |
| 29 | + def getJobState = { tbl -> |
| 30 | + def jobStateResult = sql """ SHOW ALTER TABLE COLUMN WHERE IndexName='${tbl}' ORDER BY createtime DESC LIMIT 1 """ |
| 31 | + return jobStateResult[0][9] |
| 32 | + } |
| 33 | + |
| 34 | + sql """ DROP TABLE IF EXISTS ${tableName} """ |
| 35 | + |
| 36 | + sql """ |
| 37 | + CREATE TABLE IF NOT EXISTS ${tableName} ( |
| 38 | + `k1` int(11) NULL, |
| 39 | + `k2` tinyint(4) NULL, |
| 40 | + `k3` smallint(6) NULL, |
| 41 | + `k4` int(30) NULL, |
| 42 | + `k5` largeint(40) NULL, |
| 43 | + `k6` float NULL, |
| 44 | + `k7` double NULL, |
| 45 | + `k8` decimal(9, 0) NULL, |
| 46 | + `k9` char(10) NULL, |
| 47 | + `k10` varchar(1024) NULL, |
| 48 | + `k11` text NULL, |
| 49 | + `k12` date NULL, |
| 50 | + `k13` datetime NULL |
| 51 | + ) ENGINE=OLAP |
| 52 | + UNIQUE KEY(k1, k2, k3) |
| 53 | + DISTRIBUTED BY HASH(`k1`) BUCKETS 2 |
| 54 | + PROPERTIES ( |
| 55 | + "replication_allocation" = "tag.location.default: 1", |
| 56 | + "enable_unique_key_merge_on_write" = "true" |
| 57 | + ); |
| 58 | + """ |
| 59 | + |
| 60 | + for (int i = 0; i < 100; i++) { |
| 61 | + sql """ insert into ${tableName} values ($i, 2, 3, 4, 5, 6.6, 1.7, 8.8, |
| 62 | + 'a', 'b', 'c', '2021-10-30', '2021-10-30 00:00:00') """ |
| 63 | + } |
| 64 | + |
| 65 | + |
| 66 | + // trigger compactions for all tablets in ${tableName} |
| 67 | + trigger_and_wait_compaction(tableName, "cumulative") |
| 68 | + |
| 69 | + sql """ alter table ${tableName} modify column k4 string NULL""" |
| 70 | + |
| 71 | + for (int i = 100; i < 120; i++) { |
| 72 | + sql """ insert into ${tableName} values ($i, 2, 3, 4, 5, 6.6, 1.7, 8.8, |
| 73 | + 'a', 'b', 'c', '2021-10-30', '2021-10-30 00:00:00') """ |
| 74 | + sleep(20) |
| 75 | + } |
| 76 | + |
| 77 | + Awaitility.await().atMost(30, TimeUnit.SECONDS).pollDelay(10, TimeUnit.MILLISECONDS).pollInterval(10, TimeUnit.MILLISECONDS).until( |
| 78 | + { |
| 79 | + String res = getJobState(tableName) |
| 80 | + if (res == "FINISHED" || res == "CANCELLED") { |
| 81 | + assertEquals("FINISHED", res) |
| 82 | + return true |
| 83 | + } |
| 84 | + return false |
| 85 | + } |
| 86 | + ) |
| 87 | + |
| 88 | + qt_sql """ select sum(k1), sum(k2) from ${tableName} """ |
| 89 | + } |
| 90 | +} |
| 91 | + |
0 commit comments