-
Notifications
You must be signed in to change notification settings - Fork 591
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(frontend): support alter shared source
- Loading branch information
Showing
8 changed files
with
238 additions
and
8 deletions.
There are no files selected for viewing
138 changes: 138 additions & 0 deletions
138
e2e_test/source_inline/kafka/alter/add_column_shared.slt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
control substitution on | ||
|
||
system ok | ||
rpk topic create shared_source_alter -p 4 | ||
|
||
system ok | ||
cat << EOF | rpk topic produce shared_source_alter -f "%p %v\n" -p 0 | ||
0 {"v1": 1, "v2": "a", "v3": "a1"} | ||
1 {"v1": 2, "v2": "b", "v3": "b1"} | ||
2 {"v1": 3, "v2": "c", "v3": "c1"} | ||
3 {"v1": 4, "v2": "d", "v3": "d1"} | ||
EOF | ||
|
||
statement ok | ||
create source s (v1 int, v2 varchar, v3 varchar) with ( | ||
${RISEDEV_KAFKA_WITH_OPTIONS_COMMON}, | ||
topic = 'shared_source_alter', | ||
scan.startup.mode = 'earliest' | ||
) FORMAT PLAIN ENCODE JSON; | ||
|
||
|
||
statement ok | ||
create materialized view mv_before_alter as select * from s; | ||
|
||
sleep 2s | ||
|
||
query ?? rowsort | ||
select * from s; | ||
---- | ||
1 a | ||
2 b | ||
3 c | ||
4 d | ||
|
||
query ?? rowsort | ||
select * from mv_before_alter; | ||
---- | ||
1 a | ||
2 b | ||
3 c | ||
4 d | ||
|
||
|
||
statement ok | ||
alter source s add column v3 varchar; | ||
|
||
# New MV will have v3. | ||
|
||
statement ok | ||
create materialized view mv_after_alter as select * from s; | ||
|
||
query ??? rowsort | ||
select * from mv_after_alter; | ||
---- | ||
1 a a1 | ||
2 b b1 | ||
3 c c1 | ||
4 d d1 | ||
|
||
# Batch select from source will have v3. | ||
|
||
query ??? rowsort | ||
select * from s; | ||
---- | ||
1 a a1 | ||
2 b b1 | ||
3 c c1 | ||
4 d d1 | ||
|
||
# Old MV is not affected. | ||
|
||
query ?? rowsort | ||
select * from mv_before_alter; | ||
---- | ||
1 a | ||
2 b | ||
3 c | ||
4 d | ||
|
||
# Produce new data. | ||
|
||
system ok | ||
cat << EOF | rpk topic produce shared_source_alter -f "%p %v\n" -p 0 | ||
0 {"v1": 5, "v2": "e", "v3": "e1"} | ||
1 {"v1": 6, "v2": "f", "v3": "f1"} | ||
2 {"v1": 7, "v2": "g", "v3": "g1"} | ||
3 {"v1": 8, "v2": "h", "v3": "h1"} | ||
EOF | ||
|
||
sleep 2s | ||
|
||
|
||
query ??? rowsort | ||
select * from mv_after_alter; | ||
---- | ||
1 a a1 | ||
2 b b1 | ||
3 c c1 | ||
4 d d1 | ||
5 e e1 | ||
6 f f1 | ||
7 g g1 | ||
8 h h1 | ||
|
||
|
||
# Batch select from source will have v3. | ||
|
||
query ??? rowsort | ||
select * from s; | ||
---- | ||
1 a a1 | ||
2 b b1 | ||
3 c c1 | ||
4 d d1 | ||
5 e e1 | ||
6 f f1 | ||
7 g g1 | ||
8 h h1 | ||
|
||
# Old MV is not affected. | ||
|
||
query ?? rowsort | ||
select * from mv_before_alter; | ||
---- | ||
1 a | ||
2 b | ||
3 c | ||
4 d | ||
5 e | ||
6 f | ||
7 g | ||
8 h | ||
|
||
|
||
statement ok | ||
drop source s cascade; | ||
|
||
# TODO: test alter source with schema registry |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters