-
Notifications
You must be signed in to change notification settings - Fork 590
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 source refresh schema for shared source (…
…#19740) Signed-off-by: xxchan <[email protected]>
- Loading branch information
Showing
3 changed files
with
134 additions
and
9 deletions.
There are no files selected for viewing
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
103 changes: 103 additions & 0 deletions
103
e2e_test/source_inline/kafka/protobuf/alter_source_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,103 @@ | ||
control substitution on | ||
|
||
system ok | ||
rpk topic delete pb_alter_source_shared_test || true; \ | ||
(rpk sr subject delete 'pb_alter_source_shared_test-value' && rpk sr subject delete 'pb_alter_source_shared_test-value' --permanent) || true; | ||
|
||
system ok | ||
python3 e2e_test/source_inline/kafka/protobuf/pb.py "${RISEDEV_KAFKA_BOOTSTRAP_SERVERS}" "${RISEDEV_SCHEMA_REGISTRY_URL}" "pb_alter_source_shared_test" 20 user | ||
|
||
statement ok | ||
CREATE SOURCE src_user | ||
INCLUDE timestamp -- include explicitly here to test a bug found in https://github.com/risingwavelabs/risingwave/pull/17293 | ||
WITH ( | ||
${RISEDEV_KAFKA_WITH_OPTIONS_COMMON}, | ||
topic = 'pb_alter_source_shared_test', | ||
scan.startup.mode = 'earliest' | ||
) | ||
FORMAT PLAIN ENCODE PROTOBUF( | ||
schema.registry = '${RISEDEV_SCHEMA_REGISTRY_URL}', | ||
message = 'test.User' | ||
); | ||
|
||
statement ok | ||
CREATE MATERIALIZED VIEW mv_user AS SELECT * FROM src_user; | ||
|
||
statement ok | ||
CREATE MATERIALIZED VIEW mv_user_2 AS SELECT * FROM src_user; | ||
|
||
statement ok | ||
CREATE TABLE t_user WITH ( | ||
${RISEDEV_KAFKA_WITH_OPTIONS_COMMON}, | ||
topic = 'pb_alter_source_shared_test', | ||
scan.startup.mode = 'earliest' | ||
) | ||
FORMAT PLAIN ENCODE PROTOBUF( | ||
schema.registry = '${RISEDEV_SCHEMA_REGISTRY_URL}', | ||
message = 'test.User' | ||
); | ||
|
||
# age is new field | ||
statement error | ||
SELECT age FROM mv_user; | ||
|
||
statement error | ||
SELECT age FROM t_user; | ||
|
||
# Push more events with extended fields | ||
system ok | ||
python3 e2e_test/source_inline/kafka/protobuf/pb.py "${RISEDEV_KAFKA_BOOTSTRAP_SERVERS}" "${RISEDEV_SCHEMA_REGISTRY_URL}" "pb_alter_source_shared_test" 5 user_with_more_fields | ||
|
||
sleep 5s | ||
|
||
# Refresh source schema | ||
statement ok | ||
ALTER SOURCE src_user REFRESH SCHEMA; | ||
|
||
statement ok | ||
CREATE MATERIALIZED VIEW mv_user_more AS SELECT * FROM src_user; | ||
|
||
statement ok | ||
flush; | ||
|
||
|
||
query ???? | ||
SELECT COUNT(*) FROM mv_user; | ||
---- | ||
25 | ||
|
||
query ???? | ||
SELECT COUNT(*) FROM mv_user_2; | ||
---- | ||
25 | ||
|
||
query ???? | ||
SELECT COUNT(*), MAX(age), MIN(age), SUM(age) FROM mv_user_more; | ||
---- | ||
25 104 0 510 | ||
|
||
# Push more events with extended fields | ||
system ok | ||
python3 e2e_test/source_inline/kafka/protobuf/pb.py "${RISEDEV_KAFKA_BOOTSTRAP_SERVERS}" "${RISEDEV_SCHEMA_REGISTRY_URL}" "pb_alter_source_shared_test" 5 user_with_more_fields | ||
|
||
sleep 5s | ||
|
||
|
||
query ???? | ||
SELECT COUNT(*) FROM mv_user; | ||
---- | ||
30 | ||
|
||
query ???? | ||
SELECT COUNT(*) FROM mv_user_2; | ||
---- | ||
30 | ||
|
||
query ???? | ||
SELECT COUNT(*), MAX(age), MIN(age), SUM(age) FROM mv_user_more; | ||
---- | ||
30 104 0 1020 | ||
|
||
|
||
# statement ok | ||
# DROP SOURCE src_user CASCADE; |
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