-
Notifications
You must be signed in to change notification settings - Fork 594
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support alter source add column (#11350)
- Loading branch information
Showing
26 changed files
with
565 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
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,113 @@ | ||
statement ok | ||
CREATE SOURCE s1 (v1 int) with ( | ||
connector = 'kafka', | ||
topic = 'kafka_alter', | ||
properties.bootstrap.server = 'message_queue:29092', | ||
scan.startup.mode = 'earliest' | ||
) FORMAT PLAIN ENCODE JSON; | ||
|
||
statement ok | ||
CREATE SOURCE s2 (v2 varchar) with ( | ||
connector = 'kafka', | ||
topic = 'kafka_alter', | ||
properties.bootstrap.server = 'message_queue:29092', | ||
scan.startup.mode = 'earliest' | ||
) FORMAT PLAIN ENCODE JSON; | ||
|
||
statement ok | ||
create materialized view mv1 as select * from s1; | ||
|
||
statement ok | ||
create materialized view mv2 as select * from s2; | ||
|
||
sleep 10s | ||
|
||
statement ok | ||
flush; | ||
|
||
query I | ||
select * from s1; | ||
---- | ||
1 | ||
|
||
query T | ||
select * from s2; | ||
---- | ||
11 | ||
|
||
# alter source | ||
statement ok | ||
alter source s1 add column v2 varchar; | ||
|
||
# alter source with null column | ||
statement ok | ||
alter source s2 add column v4 int; | ||
|
||
statement ok | ||
create materialized view mv3 as select * from s1; | ||
|
||
statement ok | ||
create materialized view mv4 as select * from s2; | ||
|
||
sleep 10s | ||
|
||
statement ok | ||
flush; | ||
|
||
query IT | ||
select * from s1 | ||
---- | ||
1 11 | ||
|
||
query TI | ||
select * from s2 | ||
---- | ||
11 NULL | ||
|
||
query I | ||
select * from mv1 | ||
---- | ||
1 | ||
|
||
query T | ||
select * from mv2 | ||
---- | ||
11 | ||
|
||
query IT | ||
select * from mv3 | ||
---- | ||
1 11 | ||
|
||
query TI | ||
select * from mv4 | ||
---- | ||
11 NULL | ||
|
||
# alter source again | ||
statement ok | ||
alter source s1 add column v3 int; | ||
|
||
statement ok | ||
create materialized view mv5 as select * from s1; | ||
|
||
sleep 10s | ||
|
||
statement ok | ||
flush; | ||
|
||
query ITI | ||
select * from s1 | ||
---- | ||
1 11 111 | ||
|
||
query ITI | ||
select * from mv5 | ||
---- | ||
1 11 111 | ||
|
||
# check definition after altering | ||
query TT | ||
show create source s1; | ||
---- | ||
public.s1 CREATE SOURCE s1 (v1 INT, v2 CHARACTER VARYING, v3 INT) WITH (connector = 'kafka', topic = 'kafka_alter', properties.bootstrap.server = 'message_queue:29092', scan.startup.mode = 'earliest') FORMAT PLAIN ENCODE JSON |
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,67 @@ | ||
sleep 5s | ||
|
||
statement ok | ||
flush; | ||
|
||
query IT rowsort | ||
select * from s1 | ||
---- | ||
1 11 111 | ||
2 22 222 | ||
|
||
query I rowsort | ||
select * from mv1 | ||
---- | ||
1 | ||
2 | ||
|
||
query IT rowsort | ||
select * from mv3 | ||
---- | ||
1 11 | ||
2 22 | ||
|
||
query TI rowsort | ||
select * from s2 | ||
---- | ||
11 NULL | ||
22 NULL | ||
|
||
query T rowsort | ||
select * from mv2 | ||
---- | ||
11 | ||
22 | ||
|
||
query TI rowsort | ||
select * from mv4 | ||
---- | ||
11 NULL | ||
22 NULL | ||
|
||
query ITI rowsort | ||
select * from mv5 | ||
---- | ||
1 11 111 | ||
2 22 222 | ||
|
||
statement ok | ||
drop materialized view mv1 | ||
|
||
statement ok | ||
drop materialized view mv2 | ||
|
||
statement ok | ||
drop materialized view mv3 | ||
|
||
statement ok | ||
drop materialized view mv4 | ||
|
||
statement ok | ||
drop materialized view mv5 | ||
|
||
statement ok | ||
drop source s1 | ||
|
||
statement ok | ||
drop source s2 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"v1": 2, "v2": "22", "v3": 222} |
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,18 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Exits as soon as any line fails. | ||
set -e | ||
|
||
KCAT_BIN="kcat" | ||
# kcat bin name on linux is "kafkacat" | ||
if [ "$(uname)" == "Linux" ] | ||
then | ||
KCAT_BIN="kafkacat" | ||
fi | ||
|
||
SCRIPT_PATH="$(cd "$(dirname "$0")" >/dev/null 2>&1 && pwd)" | ||
cd "$SCRIPT_PATH/.." || exit 1 | ||
|
||
FILE="./source/alter_data/kafka_alter.$1" | ||
echo "Send data from $FILE" | ||
cat $FILE | ${KCAT_BIN} -P -b message_queue:29092 -t kafka_alter |
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 @@ | ||
{"v1": 1, "v2": "11", "v3": 111} |
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
Oops, something went wrong.