Skip to content

Commit

Permalink
showing that case 2 is fixed
Browse files Browse the repository at this point in the history
Signed-off-by: Bugen Zhao <[email protected]>
  • Loading branch information
BugenZhao committed Jan 16, 2025
1 parent b93af85 commit 95ba2cd
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions e2e_test/source_inline/kafka/avro/alter_table.slt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,28 @@ select * from t
system ok
sr_register avro_alter_table_test-value AVRO <<< '{"type":"record","name":"Root","fields":[{"name":"bar","type":"int","default":0},{"name":"foo","type":"string"},{"name":"nested","type":["null",{"type":"record","name":"Nested","fields":[{"name":"baz","type":"int"}]}],"default":null}]}'

# Refresh table schema should succeed
# Before refreshing schema, we create a `SINK INTO TABLE` which involves table replacement,
# showing that this will NOT accidentally refresh the schema.
statement ok
CREATE SINK sk INTO t AS SELECT 8 AS bar, 'XYZ' AS foo WITH (type = 'append-only');

# Demonstrate purified definition
# Should not include the new field `nested`
query T
SELECT SUBSTRING(definition, 1, POSITION(' WITH' IN definition) - 1) FROM rw_tables WHERE name = 't';
----
CREATE TABLE t (bar INT, foo CHARACTER VARYING, gen_col INT AS bar + 1)

query ? rowsort
select * from t
----
1 ABC 2
8 XYZ 9

statement ok
DROP SINK sk;

# Now, refresh table schema. Should reflect the new schema.
statement ok
ALTER TABLE t REFRESH SCHEMA;

Expand All @@ -55,10 +76,11 @@ SELECT SUBSTRING(definition, 1, POSITION(' WITH' IN definition) - 1) FROM rw_tab
----
CREATE TABLE t (bar INT, foo CHARACTER VARYING, nested STRUCT<baz INT>, gen_col INT AS bar + 1)

query ?
query ? rowsort
select * from t
----
1 ABC NULL 2
8 XYZ NULL 9

# Produce a new message with the new schema
system ok
Expand All @@ -71,6 +93,7 @@ select * from t
----
1 ABC NULL 2
2 DEF (2) 3
8 XYZ NULL 9

# create a new version of schema that added a new field to "nested"
system ok
Expand Down Expand Up @@ -106,6 +129,7 @@ Caused by these errors (recent errors listed first):


# Can't drop non-generated column
# TODO(purify): may support it.
statement error
ALTER TABLE t DROP COLUMN foo;
----
Expand All @@ -129,6 +153,7 @@ select * from t
----
ABC
DEF
XYZ

statement ok
drop table t;
Expand Down

0 comments on commit 95ba2cd

Please sign in to comment.