Skip to content

Commit a60dec0

Browse files
authored
fix: fix the self-reference issue in the sink into table creation (#21103)
Signed-off-by: Shanicky Chen <[email protected]>
1 parent 1779dcc commit a60dec0

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

e2e_test/sink/sink_into_table/cycle.slt

+8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
# cycle check
2+
statement ok
3+
create table t_t(v int primary key);
4+
5+
statement error Creating such a sink will result in circular dependency
6+
create sink t_s into t_t from t_t;
27

38
statement ok
49
create table t_a(v int primary key);
@@ -33,6 +38,9 @@ drop table t_b;
3338
statement ok
3439
drop table t_c;
3540

41+
statement ok
42+
drop table t_t;
43+
3644
# cycle check (with materialize view)
3745

3846
statement ok

src/meta/src/controller/utils.rs

+5
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,11 @@ where
328328
return Ok(false);
329329
}
330330

331+
// special check for self referencing
332+
if dependent_objs.contains(&target_table) {
333+
return Ok(true);
334+
}
335+
331336
let query = construct_sink_cycle_check_query(target_table, dependent_objs);
332337
let (sql, values) = query.build_any(&*db.get_database_backend().get_query_builder());
333338

0 commit comments

Comments
 (0)