Skip to content

Commit 2aff23c

Browse files
committed
[test](regression) Add dropped base table stream lifecycle coverage
### What problem does this PR solve? Issue Number: None Related PR: apache#29 Problem Summary: Add end-to-end regression coverage proving that an IVM stream becomes disabled and stale when its base table is dropped, returns to enabled and non-stale when the original table is recovered, and remains usable for incremental refresh afterward. ### Release note None ### Check List (For Author) - Test: Regression test - ./run-regression-test.sh --run -d mtmv_p0/ivm -s test_ivm_drop_base_table_stream_state -genOut - ./run-regression-test.sh --run -d mtmv_p0/ivm -s test_ivm_drop_base_table_stream_state - Behavior changed: No. Test-only change. - Does this need documentation: No
1 parent 257b825 commit 2aff23c

2 files changed

Lines changed: 117 additions & 0 deletions

File tree

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
-- This file is automatically generated. You should know what you did if you want to edit this
2+
-- !initial_mv_rows --
3+
1 10
4+
2 20
5+
6+
-- !stream_before_drop --
7+
internal regression_test_mtmv_p0_ivm ivm_drop_base_stream_state_base OLAP true false N/A
8+
9+
-- !stream_after_drop --
10+
internal regression_test_mtmv_p0_ivm ivm_drop_base_stream_state_base N/A false true Base table does not exist
11+
12+
-- !stream_after_recover --
13+
internal regression_test_mtmv_p0_ivm ivm_drop_base_stream_state_base OLAP true false N/A
14+
15+
-- !mv_rows_after_recover --
16+
1 10
17+
2 20
18+
3 30
19+
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
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

Comments
 (0)