-
Notifications
You must be signed in to change notification settings - Fork 609
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: drop connector for table with connector (#20023)
Signed-off-by: tabversion <[email protected]> Co-authored-by: tabversion <[email protected]>
- Loading branch information
1 parent
7335fa6
commit d98b06e
Showing
24 changed files
with
714 additions
and
146 deletions.
There are no files selected for viewing
68 changes: 68 additions & 0 deletions
68
e2e_test/source_inline/cdc/mysql/mysql_alter_drop_connector.serial
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,68 @@ | ||
control substitution on | ||
|
||
system ok | ||
mysql -e " | ||
SET GLOBAL time_zone = '+01:00'; | ||
" | ||
|
||
system ok | ||
mysql -e " | ||
DROP DATABASE IF EXISTS testdb1; CREATE DATABASE testdb1; | ||
USE testdb1; | ||
CREATE TABLE tt1 (v1 int primary key, v2 varchar(255)); | ||
INSERT INTO tt1 VALUES (1, '2023-10-23 10:00:00'), (2, '2023-10-23 11:00:00'); | ||
" | ||
|
||
system ok | ||
mysql -e " | ||
DROP USER IF EXISTS 'non-shared-cdc'@'%'; | ||
CREATE USER 'non-shared-cdc'@'%' IDENTIFIED BY '123456'; | ||
GRANT SELECT, RELOAD, SHOW DATABASES, REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'non-shared-cdc'@'%'; | ||
# | ||
DROP USER IF EXISTS 'shared-cdc'@'%'; | ||
CREATE USER 'shared-cdc'@'%' IDENTIFIED BY 'abcdef'; | ||
GRANT SELECT, RELOAD, REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'shared-cdc'@'%'; | ||
# | ||
FLUSH PRIVILEGES; | ||
" | ||
|
||
statement ok | ||
CREATE TABLE table_t ( | ||
v1 int primary key, v2 varchar | ||
) with ( | ||
${RISEDEV_MYSQL_WITH_OPTIONS_COMMON}, | ||
username = 'shared-cdc', | ||
password = 'abcdef', | ||
database.name = 'testdb1', | ||
table.name = 'tt1', | ||
); | ||
|
||
sleep 1s | ||
|
||
query I | ||
select count(*) from table_t; | ||
---- | ||
2 | ||
|
||
statement ok | ||
alter table table_t drop connector; | ||
|
||
query TT | ||
show create table table_t; | ||
---- | ||
public.table_t CREATE TABLE table_t (v1 INT, v2 CHARACTER VARYING) | ||
|
||
system ok | ||
mysql -e " | ||
INSERT INTO tt1 VALUES (3, '2023-10-23 10:00:00'), (4, '2023-10-23 11:00:00'); | ||
" | ||
|
||
sleep 1s | ||
|
||
query I | ||
select count(*) from table_t; | ||
---- | ||
2 | ||
|
||
statement ok | ||
drop table table_t; |
138 changes: 138 additions & 0 deletions
138
e2e_test/source_inline/kafka/alter_table_drop_connector.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 test_alter_table_drop_connector -p 1 | ||
|
||
system ok | ||
cat <<EOF | rpk topic produce 'test_alter_table_drop_connector' -f "%k^%v\n" | ||
{"ID": 1}^{"ID": 1, "firstName": "John", "lastName": "Doe", "age": 18, "height": 5.10, "weight": 150} | ||
{"ID": 2}^{"ID": 2, "firstName": "Sarah", "lastName": "Smith", "age": 19, "height": 5.5, "weight": 120} | ||
{"ID": 3}^{"ID": 3, "firstName": "Ben", "lastName": "Johnson", "age": 21, "height": 6.0, "weight": 175} | ||
{"ID": 4}^{"ID": 4, "firstName": "Emma", "lastName": "Brown", "age": 20, "height": 5.3, "weight": 130} | ||
{"ID": 5}^{"ID": 5, "firstName": "Michael", "lastName": "Williams", "age": 22, "height": 6.2, "weight": 190} | ||
EOF | ||
|
||
statement ok | ||
CREATE TABLE plain_students ( | ||
"ID" INT, | ||
"firstName" VARCHAR, | ||
"lastName" VARCHAR, | ||
age INT, | ||
height REAL, | ||
weight REAL, | ||
) | ||
INCLUDE KEY | ||
INCLUDE PARTITION | ||
INCLUDE TIMESTAMP | ||
WITH ( | ||
${RISEDEV_KAFKA_WITH_OPTIONS_COMMON}, | ||
topic = 'test_alter_table_drop_connector') | ||
FORMAT PLAIN ENCODE JSON; | ||
|
||
statement ok | ||
flush; | ||
|
||
sleep 1s | ||
|
||
query I | ||
SELECT count(*) FROM plain_students; | ||
---- | ||
5 | ||
|
||
statement ok | ||
CREATE TABLE t_no_connector (a int, b varchar); | ||
|
||
statement error Protocol error: Table t_no_connector is not associated with a connector | ||
ALTER TABLE t_no_connector DROP CONNECTOR; | ||
|
||
statement ok | ||
ALTER TABLE plain_students DROP CONNECTOR; | ||
|
||
query TT | ||
show create table plain_students; | ||
---- | ||
public.plain_students CREATE TABLE plain_students ("ID" INT, "firstName" CHARACTER VARYING, "lastName" CHARACTER VARYING, age INT, height REAL, weight REAL, _rw_kafka_timestamp TIMESTAMP WITH TIME ZONE, _rw_kafka_partition CHARACTER VARYING, _rw_kafka_key BYTEA) | ||
|
||
system ok | ||
cat <<EOF | rpk topic produce 'test_alter_table_drop_connector' -f "%k^%v\n" | ||
{"ID": 6}^{"ID": 6, "firstName": "Leah", "lastName": "Davis", "age": 18, "height": 5.7, "weight": 140} | ||
{"ID": 7}^{"ID": 7, "firstName": "Connor", "lastName": "Wilson", "age": 19, "height": 5.9, "weight": 160} | ||
{"ID": 8}^{"ID": 8, "firstName": "Ava", "lastName": "Garcia", "age": 21, "height": 5.2, "weight": 115} | ||
EOF | ||
|
||
sleep 1s | ||
|
||
# the streaming job does not intake new data | ||
query I | ||
SELECT count(*) FROM plain_students; | ||
---- | ||
5 | ||
|
||
# ===== test with schema registry ===== | ||
|
||
system ok | ||
rpk topic delete 'avro_drop_table_connector_test' || true; \ | ||
(rpk sr subject delete 'avro_drop_table_connector_test-value' && rpk sr subject delete 'avro_drop_table_connector_test-value' --permanent) || true; | ||
|
||
system ok | ||
rpk topic create 'avro_drop_table_connector_test' | ||
|
||
system ok | ||
sr_register avro_drop_table_connector_test-value AVRO <<< '{"type":"record","name":"Root","fields":[{"name":"bar","type":"int","default":0},{"name":"foo","type":"string"}]}' | ||
|
||
system ok | ||
echo '{"foo":"ABC", "bar":1}' | rpk topic produce --schema-id=topic avro_drop_table_connector_test | ||
|
||
statement ok | ||
create table avro_drop_table_connector_test_table | ||
WITH ( | ||
${RISEDEV_KAFKA_WITH_OPTIONS_COMMON}, | ||
topic = 'avro_drop_table_connector_test' | ||
) | ||
FORMAT PLAIN ENCODE AVRO ( | ||
schema.registry = '${RISEDEV_SCHEMA_REGISTRY_URL}' | ||
); | ||
|
||
sleep 1s | ||
|
||
query ?? | ||
select foo, bar from avro_drop_table_connector_test_table | ||
---- | ||
ABC 1 | ||
|
||
statement ok | ||
alter table avro_drop_table_connector_test_table drop connector; | ||
|
||
query TT | ||
show create table avro_drop_table_connector_test_table; | ||
---- | ||
public.avro_drop_table_connector_test_table CREATE TABLE avro_drop_table_connector_test_table (bar INT, foo CHARACTER VARYING) | ||
|
||
query ?? | ||
select foo, bar from avro_drop_table_connector_test_table | ||
---- | ||
ABC 1 | ||
|
||
# produce another message | ||
system ok | ||
echo '{"foo":"DEF", "bar":2}' | rpk topic produce --schema-id=topic avro_drop_table_connector_test | ||
|
||
sleep 1s | ||
|
||
# the new message is not ingested | ||
query ?? | ||
select foo, bar from avro_drop_table_connector_test_table | ||
---- | ||
ABC 1 | ||
|
||
# ===== clean up ===== | ||
|
||
statement ok | ||
DROP TABLE plain_students; | ||
|
||
statement ok | ||
drop table avro_drop_table_connector_test_table; | ||
|
||
system ok | ||
rpk topic delete 'avro_drop_table_connector_test' || true; \ | ||
(rpk sr subject delete 'avro_drop_table_connector_test-value' && rpk sr subject delete 'avro_drop_table_connector_test-value' --permanent) || true; |
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.