Skip to content

Commit 84d1225

Browse files
authored
feat(frontend): allow users to confirm if background_ddl is enabled for a sink (#24338)
Signed-off-by: StandingMan <jmtangcs@gmail.com>
1 parent 4a21a24 commit 84d1225

File tree

3 files changed

+141
-36
lines changed

3 files changed

+141
-36
lines changed
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
# Test whether sinks, materialized views, and indexes run in the background
2+
3+
# Test index part
4+
statement ok
5+
create table t(v1 int);
6+
7+
statement ok
8+
insert into t select * from generate_series(1, 500000);
9+
10+
statement ok
11+
set background_ddl=false;
12+
13+
statement ok
14+
CREATE INDEX index1 ON t (v1);
15+
16+
query I
17+
select background_ddl from rw_catalog.rw_indexes where name='index1';
18+
----
19+
f
20+
21+
statement ok
22+
set background_ddl=true;
23+
24+
statement ok
25+
CREATE INDEX index2 ON t (v1);
26+
27+
query I
28+
select background_ddl from rw_catalog.rw_indexes where name='index2';
29+
----
30+
t
31+
32+
statement ok
33+
drop index index1;
34+
35+
statement ok
36+
drop index index2;
37+
38+
statement ok
39+
drop table t;
40+
41+
statement ok
42+
set background_ddl=false;
43+
44+
# Test sink part
45+
statement ok
46+
SET RW_IMPLICIT_FLUSH TO true;
47+
48+
statement ok
49+
SET sink_decouple TO true;
50+
51+
statement ok
52+
create table t(v1 int);
53+
54+
statement ok
55+
set backfill_rate_limit=5000;
56+
57+
statement ok
58+
insert into t select * from generate_series(1, 10000);
59+
60+
statement ok
61+
CREATE SINK sink1 AS select * from t WITH (
62+
connector = 'blackhole'
63+
);
64+
65+
query I
66+
select background_ddl from rw_catalog.rw_sinks where name='sink1';
67+
----
68+
f
69+
70+
statement ok
71+
set background_ddl=true;
72+
73+
statement ok
74+
CREATE SINK sink2 AS select * from t WITH (
75+
connector = 'blackhole'
76+
);
77+
78+
query I
79+
select background_ddl from rw_catalog.rw_sinks where name='sink2';
80+
----
81+
t
82+
83+
statement ok
84+
drop sink sink1;
85+
86+
statement ok
87+
drop sink sink2;
88+
89+
statement ok
90+
drop table t;
91+
92+
statement ok
93+
set background_ddl=false;
94+
95+
# Test materialized view part
96+
statement ok
97+
create table t(v1 int);
98+
99+
statement ok
100+
insert into t select * from generate_series(1, 10000);
101+
102+
statement ok
103+
set backfill_rate_limit=5000;
104+
105+
statement ok
106+
create materialized view m1 as select * from t;
107+
108+
query I
109+
select background_ddl from rw_catalog.rw_materialized_views where name='m1';
110+
----
111+
f
112+
113+
statement ok
114+
set background_ddl=true;
115+
116+
statement ok
117+
create materialized view m2 as select * from t;
118+
119+
query I
120+
select background_ddl from rw_catalog.rw_materialized_views where name='m2';
121+
----
122+
t
123+
124+
statement ok
125+
drop materialized view m1;
126+
127+
statement ok
128+
drop materialized view m2;
129+
130+
statement ok
131+
drop table t;
132+
133+
statement ok
134+
set background_ddl=false;
135+
136+
statement ok
137+
set backfill_rate_limit=default;
138+

e2e_test/background_ddl/check_background_index.slt

Lines changed: 0 additions & 36 deletions
This file was deleted.

src/frontend/src/catalog/system_catalog/rw_catalog/rw_sinks.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
use risingwave_common::catalog::CreateType;
1516
use risingwave_common::id::{ConnectionId, SchemaId, SinkId, UserId};
1617
use risingwave_common::types::{Fields, JsonbVal, Timestamptz};
1718
use risingwave_connector::WithOptionsSecResolved;
@@ -38,6 +39,7 @@ struct RwSink {
3839
created_at: Option<Timestamptz>,
3940
initialized_at_cluster_version: Option<String>,
4041
created_at_cluster_version: Option<String>,
42+
background_ddl: bool,
4143

4244
// connector properties in json format
4345
connector_props: JsonbVal,
@@ -101,6 +103,7 @@ fn read_rw_sinks_info(reader: &SysCatalogReaderImpl) -> Result<Vec<RwSink>> {
101103
created_at_cluster_version: sink.created_at_cluster_version.clone(),
102104
connector_props,
103105
format_encode_options,
106+
background_ddl: sink.create_type == CreateType::Background,
104107
}
105108
})
106109
})

0 commit comments

Comments
 (0)