Skip to content

Commit d78e9aa

Browse files
committed
add test and more check
1 parent 7561140 commit d78e9aa

2 files changed

Lines changed: 68 additions & 1 deletion

File tree

e2e_test/streaming/batch_refresh_snapshot.slt

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,65 @@ DROP TABLE IF EXISTS t_batch;
1010
statement ok
1111
CREATE TABLE t_batch (v1 int);
1212

13+
# ── Tests: SQL operations forbidden for batch refresh MVs ────────────────────
14+
15+
statement ok
16+
CREATE MATERIALIZED VIEW mv_up AS SELECT * FROM t_batch;
17+
18+
statement ok
19+
CREATE MATERIALIZED VIEW mv_batch WITH (refresh.interval.sec = 5) AS
20+
SELECT * FROM mv_up;
21+
22+
statement error ALTER MATERIALIZED VIEW is not supported for batch refresh materialized views
23+
ALTER MATERIALIZED VIEW mv_batch AS SELECT v1 + 1 AS v1 FROM mv_up;
24+
25+
statement ok
26+
DROP MATERIALIZED VIEW mv_batch;
27+
28+
statement ok
29+
DROP MATERIALIZED VIEW mv_up;
30+
31+
# ── Tests: streaming/batch-refresh jobs cannot depend on a batch-refresh MV ──
32+
33+
statement ok
34+
CREATE MATERIALIZED VIEW mv_up AS SELECT * FROM t_batch;
35+
36+
statement ok
37+
CREATE MATERIALIZED VIEW mv_batch WITH (refresh.interval.sec = 5) AS
38+
SELECT * FROM mv_up;
39+
40+
statement error creating streaming jobs on batch refresh materialized views is not supported
41+
CREATE MATERIALIZED VIEW mv_on_batch AS SELECT * FROM mv_batch;
42+
43+
statement error creating streaming jobs on batch refresh materialized views is not supported
44+
CREATE MATERIALIZED VIEW mv_batch_on_batch WITH (refresh.interval.sec = 5) AS
45+
SELECT * FROM mv_batch;
46+
47+
statement ok
48+
DROP MATERIALIZED VIEW mv_batch;
49+
50+
statement ok
51+
DROP MATERIALIZED VIEW mv_up;
52+
53+
# ── Tests: batch refresh MV cannot read directly from a source ────────────────
54+
55+
statement ok
56+
CREATE SOURCE src_test (v1 int) WITH (
57+
connector = 'datagen',
58+
fields.v1.kind = 'sequence',
59+
fields.v1.start = '1',
60+
datagen.rows.per.second = '1'
61+
);
62+
63+
statement error batch refresh materialized views must not depend on sources
64+
CREATE MATERIALIZED VIEW mv_batch_source_bad WITH (refresh.interval.sec = 5) AS
65+
SELECT * FROM src_test;
66+
67+
statement ok
68+
DROP SOURCE src_test;
69+
70+
# ── Tests: batch refresh periodic refresh behavior ───────────────────────────
71+
1372
statement ok
1473
INSERT INTO t_batch VALUES (1), (2);
1574

src/frontend/src/handler/alter_mv.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ async fn handle_alter_mv_bound(
146146

147147
// TODO(alter-mv): use `ColumnIdGenerator` to generate IDs for MV columns, in order to
148148
// support schema changes.
149-
let (mut table, graph, _dependencies, _resource_group, _refresh_interval_sec) = {
149+
let (mut table, graph, _dependencies, _resource_group, refresh_interval_sec) = {
150150
create_mv::gen_create_mv_graph(
151151
handler_args,
152152
name,
@@ -160,6 +160,14 @@ async fn handle_alter_mv_bound(
160160
.await?
161161
};
162162

163+
if refresh_interval_sec.is_some() {
164+
return Err(ErrorCode::InvalidInputSyntax(
165+
"ALTER MATERIALIZED VIEW is not supported for batch refresh materialized views"
166+
.to_owned(),
167+
)
168+
.into());
169+
}
170+
163171
// After alter, the data of the MV is not guaranteed to be consistent.
164172
// Always set the conflict handler to avoid producing inconsistent changes to downstream.
165173
table.conflict_behavior = ConflictBehavior::Overwrite;

0 commit comments

Comments
 (0)