Skip to content

Commit 25a4809

Browse files
authored
feat(streaming): only output required columns for MV-on-MV (risingwavelabs#8555)
Signed-off-by: Bugen Zhao <[email protected]>
1 parent 64a5f88 commit 25a4809

File tree

16 files changed

+267
-341
lines changed

16 files changed

+267
-341
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dashboard/proto/gen/catalog.ts

Lines changed: 18 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dashboard/proto/gen/expr.ts

Lines changed: 10 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dashboard/proto/gen/stream_plan.ts

Lines changed: 18 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

e2e_test/ddl/alter_table_column.slt

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ select * from mv3;
127127
3 3.3 3-3
128128

129129
# Drop column
130-
# TODO(#4529): create mview on partial columns and test whether dropping the unrefereced column works.
131130
statement error being referenced
132131
alter table t drop column s;
133132

@@ -137,6 +136,10 @@ drop materialized view mv2;
137136
statement ok
138137
drop materialized view mv3;
139138

139+
statement ok
140+
create materialized view mv5 as select v, s from t;
141+
142+
# This should succeed as there's no materialized view referencing the column, including `mv5`. (#4529)
140143
statement ok
141144
alter table t drop column r;
142145

@@ -152,6 +155,13 @@ select v, s from t;
152155
2 NULL
153156
3 3-3
154157

158+
query IR rowsort
159+
select v, s from mv5;
160+
----
161+
1 1-1
162+
2 NULL
163+
3 3-3
164+
155165
# Add column after dropping column, to test that the column ID is not reused.
156166
statement ok
157167
alter table t add column r real;
@@ -191,6 +201,9 @@ select v, s, r from t;
191201
4 4-4 4.4
192202

193203
# Clean up
204+
statement ok
205+
drop materialized view mv5;
206+
194207
statement ok
195208
drop materialized view mv;
196209

proto/stream_plan.proto

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -384,14 +384,16 @@ enum ChainType {
384384
// 2. BatchPlanNode for snapshot read.
385385
message ChainNode {
386386
uint32 table_id = 1;
387-
// The schema of input stream, which will be used to build a MergeNode
388-
repeated plan_common.Field upstream_fields = 2;
389-
// The columns from the upstream table to output.
390-
// TODO: rename this field.
391-
repeated uint32 upstream_column_indices = 3;
387+
392388
// The columns from the upstream table that'll be internally required by this chain node.
393-
// TODO: This is currently only used by backfill table scan. We should also apply it to the upstream dispatcher (#4529).
394-
repeated int32 upstream_column_ids = 8;
389+
// - For non-backfill chain node, it's the same as the output columns.
390+
// - For backfill chain node, there're additionally primary key columns.
391+
repeated int32 upstream_column_ids = 2;
392+
// The columns to be output by this chain node. The index is based on the internal required columns.
393+
// - For non-backfill chain node, it's simply all the columns.
394+
// - For backfill chain node, this strips the primary key columns if they're unnecessary.
395+
repeated uint32 output_indices = 3;
396+
395397
// Generally, the barrier needs to be rearranged during the MV creation process, so that data can
396398
// be flushed to shared buffer periodically, instead of making the first epoch from batch query extra
397399
// large. However, in some cases, e.g., shared state, the barrier cannot be rearranged in ChainNode.

0 commit comments

Comments
 (0)