|
| 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_ivm_drop_base_table_stream_state") { |
| 19 | + sql "DROP MATERIALIZED VIEW IF EXISTS ivm_drop_base_stream_state_mv" |
| 20 | + sql "DROP TABLE IF EXISTS ivm_drop_base_stream_state_base" |
| 21 | + |
| 22 | + sql """ |
| 23 | + CREATE TABLE ivm_drop_base_stream_state_base ( |
| 24 | + id BIGINT NOT NULL, |
| 25 | + value BIGINT |
| 26 | + ) UNIQUE KEY(id) |
| 27 | + DISTRIBUTED BY HASH(id) BUCKETS 1 |
| 28 | + PROPERTIES ( |
| 29 | + "replication_num" = "1", |
| 30 | + "enable_unique_key_merge_on_write" = "true", |
| 31 | + "binlog.enable" = "true", |
| 32 | + "binlog.format" = "ROW", |
| 33 | + "binlog.need_historical_value" = "true" |
| 34 | + ) |
| 35 | + """ |
| 36 | + sql "INSERT INTO ivm_drop_base_stream_state_base VALUES (1, 10), (2, 20)" |
| 37 | + |
| 38 | + sql """ |
| 39 | + CREATE MATERIALIZED VIEW ivm_drop_base_stream_state_mv |
| 40 | + BUILD DEFERRED REFRESH INCREMENTAL ON MANUAL |
| 41 | + DISTRIBUTED BY RANDOM BUCKETS 1 |
| 42 | + PROPERTIES ("replication_num" = "1") |
| 43 | + AS SELECT id, value FROM ivm_drop_base_stream_state_base |
| 44 | + """ |
| 45 | + |
| 46 | + sql "REFRESH MATERIALIZED VIEW ivm_drop_base_stream_state_mv INCREMENTAL" |
| 47 | + waitingMTMVTaskFinishedByMvName("ivm_drop_base_stream_state_mv") |
| 48 | + |
| 49 | + order_qt_initial_mv_rows """ |
| 50 | + SELECT id, value |
| 51 | + FROM ivm_drop_base_stream_state_mv |
| 52 | + ORDER BY id |
| 53 | + """ |
| 54 | + |
| 55 | + order_qt_stream_before_drop """ |
| 56 | + SELECT BASE_TABLE_CTL, BASE_TABLE_DB, BASE_TABLE_NAME, BASE_TABLE_TYPE, |
| 57 | + ENABLED, IS_STALE, STALE_REASON |
| 58 | + FROM information_schema.table_streams |
| 59 | + WHERE DB_NAME = '${context.dbName}' |
| 60 | + AND BASE_TABLE_NAME = 'ivm_drop_base_stream_state_base' |
| 61 | + AND starts_with(STREAM_NAME, '__doris_ivm_stream_') |
| 62 | + ORDER BY STREAM_NAME |
| 63 | + """ |
| 64 | + |
| 65 | + sql "DROP TABLE ivm_drop_base_stream_state_base" |
| 66 | + |
| 67 | + order_qt_stream_after_drop """ |
| 68 | + SELECT BASE_TABLE_CTL, BASE_TABLE_DB, BASE_TABLE_NAME, BASE_TABLE_TYPE, |
| 69 | + ENABLED, IS_STALE, STALE_REASON |
| 70 | + FROM information_schema.table_streams |
| 71 | + WHERE DB_NAME = '${context.dbName}' |
| 72 | + AND BASE_TABLE_NAME = 'ivm_drop_base_stream_state_base' |
| 73 | + AND starts_with(STREAM_NAME, '__doris_ivm_stream_') |
| 74 | + ORDER BY STREAM_NAME |
| 75 | + """ |
| 76 | + |
| 77 | + sql "RECOVER TABLE ivm_drop_base_stream_state_base" |
| 78 | + |
| 79 | + order_qt_stream_after_recover """ |
| 80 | + SELECT BASE_TABLE_CTL, BASE_TABLE_DB, BASE_TABLE_NAME, BASE_TABLE_TYPE, |
| 81 | + ENABLED, IS_STALE, STALE_REASON |
| 82 | + FROM information_schema.table_streams |
| 83 | + WHERE DB_NAME = '${context.dbName}' |
| 84 | + AND BASE_TABLE_NAME = 'ivm_drop_base_stream_state_base' |
| 85 | + AND starts_with(STREAM_NAME, '__doris_ivm_stream_') |
| 86 | + ORDER BY STREAM_NAME |
| 87 | + """ |
| 88 | + |
| 89 | + sql "INSERT INTO ivm_drop_base_stream_state_base VALUES (3, 30)" |
| 90 | + sql "REFRESH MATERIALIZED VIEW ivm_drop_base_stream_state_mv INCREMENTAL" |
| 91 | + waitingMTMVTaskFinishedByMvName("ivm_drop_base_stream_state_mv") |
| 92 | + |
| 93 | + order_qt_mv_rows_after_recover """ |
| 94 | + SELECT id, value |
| 95 | + FROM ivm_drop_base_stream_state_mv |
| 96 | + ORDER BY id |
| 97 | + """ |
| 98 | +} |
0 commit comments