Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
KeXiangWang committed Sep 20, 2024
1 parent d356b8d commit 212d9df
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 122 deletions.
123 changes: 2 additions & 121 deletions e2e_test/source/cdc/cdc.load.slt
Original file line number Diff line number Diff line change
@@ -1,48 +1,6 @@
# CDC source basic test
control substitution on

statement ok
create table products ( id INT,
name STRING,
description STRING,
PRIMARY KEY (id)
) with (
connector = 'mysql-cdc',
hostname = 'mysql',
port = '3306',
username = 'dbz',
password = '123456',
database.name = 'my@db',
table.name = 'products',
server.id = '5085'
);

statement ok
create materialized view products_cnt as select count(*) as cnt from products;

statement ok
create table orders (
order_id int,
order_date timestamp,
customer_name string,
price decimal,
product_id int,
order_status smallint,
PRIMARY KEY (order_id)
) with (
connector = 'mysql-cdc',
hostname = 'mysql',
port = '3306',
username = 'dbz',
password = '123456',
database.name = 'my@db',
table.name = 'orders',
server.id = '5086'
);

statement ok
create materialized view orders_cnt as select count(*) as cnt from orders;

statement ok
create table shipments (
shipment_id INTEGER,
Expand All @@ -62,83 +20,6 @@ create table shipments (
slot.name = 'shipments'
);

statement ok
create materialized view shipments_cnt as select count(*) as cnt from shipments;

# Create a mview upon above three tables
statement ok
create materialized view enriched_orders as SELECT o.*, p.name, p.description, s.shipment_id, s.origin, s.destination, s.is_arrived
FROM orders AS o
LEFT JOIN products AS p ON o.product_id = p.id
LEFT JOIN shipments AS s ON o.order_id = s.order_id;

statement ok
create table mytable (
v1 INTEGER,
v2 INTEGER,
v3 STRING,
PRIMARY KEY (v1)
) with (
connector = 'mysql-cdc',
hostname = 'mysql',
port = '3306',
username = 'root',
password = '123456',
database.name = 'my@db',
table.name = 'mytable',
server.id = '5087'
);

# Some columns missing and reordered (mysql-cdc)
statement ok
create table orders_2 (
order_id int,
price decimal,
customer_name string,
PRIMARY KEY (order_id)
) with (
connector = 'mysql-cdc',
hostname = 'mysql',
port = '3306',
username = 'root',
password = '123456',
database.name = 'my@db',
table.name = 'orders',
server.id = '5088'
);

statement error
create table tt3_rw (
v1 int,
v2 timestamp,
PRIMARY KEY (v1)
) with (
connector = 'mysql-cdc',
hostname = 'mysql',
port = '3306',
username = 'root',
password = '123456',
database.name = 'my@db',
table.name = 'tt3',
server.id = '5089'
);

statement ok
create table tt3_rw (
v1 int,
v2 timestamptz,
PRIMARY KEY (v1)
) with (
connector = 'mysql-cdc',
hostname = 'mysql',
port = '3306',
username = 'root',
password = '123456',
database.name = 'my@db',
table.name = 'tt3',
server.id = '5089'
);

# Some columns missing and reordered (postgres-cdc)
statement ok
create table shipments_2 (
Expand Down Expand Up @@ -274,7 +155,7 @@ CREATE TABLE IF NOT EXISTS partitioned_timestamp_table(
database.name = '${PGDATABASE:postgres}',
schema.name = 'public',
table.name = 'partitioned_timestamp_table',
publication.name = 'rw_publication',
publication.name = 'rw_publication_partitioned_table',
slot.name = 'my_slot_partition'
);

Expand All @@ -294,6 +175,6 @@ CREATE TABLE IF NOT EXISTS partitioned_timestamp_table_2023(
database.name = '${PGDATABASE:postgres}',
schema.name = 'public',
table.name = 'partitioned_timestamp_table_2023',
publication.name = 'rw_publication',
publication.name = 'rw_publication_partitioned_table',
slot.name = 'my_slot_partition_2'
);
1 change: 1 addition & 0 deletions e2e_test/source/cdc/postgres_cdc.sql
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,5 @@ INSERT INTO partitioned_timestamp_table (c_int, c_boolean, c_timestamp) VALUES
(8, false, '2025-01-08 18:30:00'),
(9, false, '2025-07-09 07:10:00');

-- Here we create this publication without `WITH ( publish_via_partition_root = true )` only for tests. Normally, it should be added.
create publication rw_publication_pubviaroot_false for TABLE partitioned_timestamp_table;
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ public void testPermissionCheck() throws SQLException {
"CREATE TABLE IF NOT EXISTS orders (o_key BIGINT NOT NULL, o_val INT, PRIMARY KEY (o_key))";
SourceTestClient.performQuery(connDbz, query);
// create a partial publication, check whether error is reported
query = "CREATE PUBLICATION rw_publication FOR TABLE orders (o_key)";
query =
"CREATE PUBLICATION rw_publication FOR TABLE orders (o_key) WITH ( publish_via_partition_root = true );";
SourceTestClient.performQuery(connDbz, query);
ConnectorServiceProto.TableSchema tableSchema =
ConnectorServiceProto.TableSchema.newBuilder()
Expand Down

0 comments on commit 212d9df

Please sign in to comment.