The Flink CDC connector for PolarDB for PostgreSQL (Compatible with Oracle), referred to as the PolarDB-O Flink CDC connector, reads a full data snapshot and then incremental changes from a PolarDB for PostgreSQL (Compatible with Oracle) database. For its features and usage, refer to the community Postgres CDC documentation.
Because PolarDB for PostgreSQL (Compatible with Oracle) and community PostgreSQL have only minor differences in data types and the handling of built-in objects, this article describes how you can adapt the community Postgres CDC connector with minor code changes to package a PolarDB Flink CDC connector for PolarDB for PostgreSQL (Compatible with Oracle).
The DATE type in PolarDB for PostgreSQL (Compatible with Oracle) is 64-bit, whereas in community PostgreSQL, it is 32-bit. The PolarDB-O Flink CDC connector handles this difference.
Build the PolarDB-O Flink CDC
The PolarDB-O Flink CDC connector is adapted from the community Postgres CDC. No service-level agreement (SLA) is provided for the connector, regardless of whether you build it yourself or use the JAR package provided in this topic.
Prerequisites
-
Determine the Flink-CDC version
If you use Alibaba Cloud Realtime Compute for Apache Flink, you must determine the community Flink-CDC version that is compatible with your Ververica Runtime (VVR) version. For more information, see CDC and VVR Version Mapping.
NoteThe Flink-CDC code repository is available at Flink-CDC.
-
Determine the Debezium version
In the
pom.xmlfile of the corresponding Flink-CDC version, find thedebezium.versionproperty to determine the Debezium version.NoteThe Debezium code repository is available at Debezium.
-
Determine the PgJDBC version
In the
pom.xmlfile of the corresponding Postgres-CDC version, find theorg.postgresqldependency to determine the PgJDBC version.Note-
For versions earlier than release-3.0, the file path is
flink-connector-postgres-cdc/pom.xml. -
For release-3.0 and later, the file path is
flink-cdc-connect/flink-cdc-source-connectors/flink-connector-postgres-cdc/pom.xml. -
The PgJDBC code repository is available at PgJDBC.
-
Procedure
Build for release-3.5
Community Flink-CDC release-3.5 is compatible with vvr-11.4-jdk11-flink-1.20 of Alibaba Cloud Realtime Compute for Apache Flink.
To build the PolarDB-O Flink CDC connector for this version, follow these steps:
-
Clone the repositories for the corresponding versions of Flink-CDC, Debezium, and PgJDBC.
git clone -b release-3.5 --depth=1 https://github.com/apache/flink-cdc.git git clone -b REL42.7.3 --depth=1 https://github.com/pgjdbc/pgjdbc.git git clone -b v1.9.8.Final --depth=1 https://github.com/debezium/debezium.git -
Copy the required files from the Debezium and PgJDBC repositories into the Flink-CDC directory.
mkdir -p flink-cdc/flink-cdc-connect/flink-cdc-source-connectors/flink-connector-postgres-cdc/src/main/java/org/postgresql/core/v3 mkdir -p flink-cdc/flink-cdc-connect/flink-cdc-source-connectors/flink-connector-postgres-cdc/src/main/java/org/postgresql/jdbc cp pgjdbc/pgjdbc/src/main/java/org/postgresql/core/v3/ConnectionFactoryImpl.java flink-cdc/flink-cdc-connect/flink-cdc-source-connectors/flink-connector-postgres-cdc/src/main/java/org/postgresql/core/v3 cp pgjdbc/pgjdbc/src/main/java/org/postgresql/core/v3/QueryExecutorImpl.java flink-cdc/flink-cdc-connect/flink-cdc-source-connectors/flink-connector-postgres-cdc/src/main/java/org/postgresql/core/v3 cp pgjdbc/pgjdbc/src/main/java/org/postgresql/jdbc/PgDatabaseMetaData.java flink-cdc/flink-cdc-connect/flink-cdc-source-connectors/flink-connector-postgres-cdc/src/main/java/org/postgresql/jdbc cp pgjdbc/pgjdbc/src/main/java/org/postgresql/core/Oid.java flink-cdc/flink-cdc-connect/flink-cdc-source-connectors/flink-connector-postgres-cdc/src/main/java/org/postgresql/core cp debezium/debezium-connector-postgres/src/main/java/io/debezium/connector/postgresql/TypeRegistry.java flink-cdc/flink-cdc-connect/flink-cdc-source-connectors/flink-connector-postgres-cdc/src/main/java/io/debezium/connector/postgresql -
Navigate to the Flink-CDC directory and apply the timestamp conversion bug fix and the implicit behavior (SELECT *) bug fix. These fixes are scheduled for inclusion in community release 3.6.
cd flink-cdc # Apply the bug fix for timestamp conversion, which will be merged into community release 3.6. git fetch origin 2f32836a783f80f295c9dce339c11afec2a32dc2 git cherry-pick 2f32836a783f80f295c9dce339c11afec2a32dc2 git fetch origin 0d86de24494a855c2d83f9b1052c2e888e182cb1 git cherry-pick 0d86de24494a855c2d83f9b1052c2e888e182cb1 -
Apply the patch file to ensure compatibility with PolarDB for PostgreSQL (Compatible with Oracle).
git apply release-3.5_support_polardbo.patchNoteYou can download the patch file used in this step here: release-3.5_support_polardbo.patch.
-
Use Maven to build the PolarDB-O Flink CDC connector.
mvn clean install -DskipTests -Dcheckstyle.skip=true -Dspotless.check.skip # After the build is complete, the JAR package is located in the flink-cdc-connect/flink-cdc-pipeline-connectors/flink-cdc-pipeline-connector-postgres/target directory.
The following JAR package for the PolarDB-O Flink CDC connector is built with JDK 11 by following the steps above: flink-cdc-pipeline-connector-polardbo-3.5-SNAPSHOT-20260212.jar.
Build for release-3.1
Community Flink-CDC release-3.1 is compatible with vvr-8.0.x-flink-1.17 of Alibaba Cloud Realtime Compute for Apache Flink.
To build the PolarDB-O Flink CDC connector for this version, follow these steps:
-
Clone the repositories for the corresponding versions of Flink-CDC, Debezium, and PgJDBC.
git clone -b release-3.1 --depth=1 https://github.com/apache/flink-cdc.git git clone -b REL42.5.1 --depth=1 https://github.com/pgjdbc/pgjdbc.git git clone -b v1.9.8.Final --depth=1 https://github.com/debezium/debezium.git -
Copy the required files from the Debezium and PgJDBC repositories into the Flink-CDC directory.
mkdir -p flink-cdc/flink-cdc-connect/flink-cdc-source-connectors/flink-connector-postgres-cdc/src/main/java/org/postgresql/core/v3 mkdir -p flink-cdc/flink-cdc-connect/flink-cdc-source-connectors/flink-connector-postgres-cdc/src/main/java/org/postgresql/jdbc cp pgjdbc/pgjdbc/src/main/java/org/postgresql/core/v3/ConnectionFactoryImpl.java flink-cdc/flink-cdc-connect/flink-cdc-source-connectors/flink-connector-postgres-cdc/src/main/java/org/postgresql/core/v3 cp pgjdbc/pgjdbc/src/main/java/org/postgresql/core/v3/QueryExecutorImpl.java flink-cdc/flink-cdc-connect/flink-cdc-source-connectors/flink-connector-postgres-cdc/src/main/java/org/postgresql/core/v3 cp pgjdbc/pgjdbc/src/main/java/org/postgresql/jdbc/PgDatabaseMetaData.java flink-cdc/flink-cdc-connect/flink-cdc-source-connectors/flink-connector-postgres-cdc/src/main/java/org/postgresql/jdbc cp debezium/debezium-connector-postgres/src/main/java/io/debezium/connector/postgresql/TypeRegistry.java flink-cdc/flink-cdc-connect/flink-cdc-source-connectors/flink-connector-postgres-cdc/src/main/java/io/debezium/connector/postgresql -
Apply the patch file to ensure compatibility with PolarDB for PostgreSQL (Compatible with Oracle).
git apply release-3.1_support_polardbo.patchNoteYou can download the patch file used in this step here: release-3.1_support_polardbo.patch.
-
Use Maven to build the PolarDB-O Flink CDC connector.
mvn clean install -DskipTests -Dcheckstyle.skip=true -Dspotless.check.skip -Drat.skip=true # After the build is complete, the JAR package is located in the flink-sql-connector-postgres-cdc/target directory.
The following JAR package for the PolarDB-O Flink CDC connector is built with JDK 8 by following the steps above: flink-sql-connector-postgres-cdc-3.1-SNAPSHOT.jar.
Build for release-2.3
Community Flink-CDC release-2.3 is compatible with vvr-4.0.15-flink-1.13 to vvr-6.0.2-flink-1.15 of Alibaba Cloud Realtime Compute for Apache Flink.
To build the PolarDB-O Flink CDC connector for this version, follow these steps:
-
Clone the repositories for the corresponding versions of Flink-CDC, Debezium, and PgJDBC.
git clone -b release-2.3 --depth=1 https://github.com/apache/flink-cdc.git git clone -b REL42.2.26 --depth=1 https://github.com/pgjdbc/pgjdbc.git git clone -b v1.6.4.Final --depth=1 https://github.com/debezium/debezium.git -
Copy the required files from the Debezium and PgJDBC repositories into the Flink-CDC directory.
mkdir -p flink-cdc/flink-connector-postgres-cdc/src/main/java/org/postgresql/core/v3 mkdir -p flink-cdc/flink-connector-postgres-cdc/src/main/java/org/postgresql/jdbc mkdir -p flink-cdc/flink-connector-postgres-cdc/src/main/java/io/debezium/connector/postgresql cp pgjdbc/pgjdbc/src/main/java/org/postgresql/core/v3/ConnectionFactoryImpl.java flink-cdc/flink-connector-postgres-cdc/src/main/java/org/postgresql/core/v3 cp pgjdbc/pgjdbc/src/main/java/org/postgresql/core/v3/QueryExecutorImpl.java flink-cdc/flink-connector-postgres-cdc/src/main/java/org/postgresql/core/v3 cp pgjdbc/pgjdbc/src/main/java/org/postgresql/jdbc/PgDatabaseMetaData.java flink-cdc/flink-connector-postgres-cdc/src/main/java/org/postgresql/jdbc cp debezium/debezium-connector-postgres/src/main/java/io/debezium/connector/postgresql/TypeRegistry.java flink-cdc/flink-connector-postgres-cdc/src/main/java/io/debezium/connector/postgresql -
Apply the patch file to ensure compatibility with PolarDB for PostgreSQL (Compatible with Oracle).
git apply release-2.3_support_polardbo.patchNoteYou can download the patch file used in this step here: release-2.3_support_polardbo.patch.
-
Use Maven to build the PolarDB-O Flink CDC connector.
mvn clean install -DskipTests -Dcheckstyle.skip=true -Dspotless.check.skip -Drat.skip=true # After the build is complete, the JAR package is located in the flink-sql-connector-postgres-cdc/target directory.
The following JAR package for the PolarDB-O Flink CDC connector is built with JDK 8 by following the steps above: flink-sql-connector-postgres-cdc-2.3-SNAPSHOT.jar.
Usage
The PolarDB-O Flink CDC connector reads CDC data streams from a PolarDB for PostgreSQL (Compatible with Oracle) database by using logical replication. This requires the following:
-
Set the
wal_levelparameter tological. This setting adds the required information for logical replication to the write-ahead logging (WAL) files.NoteYou can set the wal_level parameter in the console. For detailed instructions, see Set cluster parameters. Modifying this parameter restarts the cluster. Schedule this operation carefully to minimize impact on your business.
-
Execute the
ALTER TABLE schema.table REPLICA IDENTITY FULL;command to set theREPLICA IDENTITYof the subscribed table toFULL. This ensures that INSERT and UPDATE events contain the previous values of all columns, which is necessary for data consistency.Note-
REPLICA IDENTITY is a table-level setting in PostgreSQL that determines whether the logical decoding plugin includes the old values of columns for INSERT and UPDATE events. For more information about REPLICA IDENTITY values, see REPLICA IDENTITY.
-
Setting the
REPLICA IDENTITYof a subscribed table toFULLmight require a table lock and impact your business operations. Plan accordingly. You can use the following command to check if the current configuration isFULL:SELECT relreplident = 'f' FROM pg_class WHERE relname = 'tablename';
-
-
Ensure that the values of the max_wal_senders and max_replication_slots parameters exceed the sum of the currently used replication slots and the number of slots required by the Flink job.
-
Use a privileged account, or an account that has both LOGIN and REPLICATION permissions. The account must also have SELECT permission on the subscribed tables to perform the initial snapshot query.
-
You can only connect to the primary endpoint of the PolarDB cluster. Cluster endpoints do not support logical replication.
-
Release 3.5 and later support synchronizing a partitioned table by specifying its parent table. The following configurations are required. For details, see the Postgres CDC community documentation.
-
Set the
scan.include-partitioned-tables.enabledoption totrue. -
Manually create a
PUBLICATIONin the database with thepublish_via_partition_root=trueoption. Then, use thedebezium.publication.nameparameter to specify thetable-name. -
The
table-namemust specify only the parent table. The regular expression must not match child tables, which would cause data duplication during the snapshot phase.
Additionally, release 3.5 and later support the pipeline connector, which allows reading snapshot and incremental data and provides end-to-end full database synchronization. However, the pipeline connector does not currently support schema changes. For details, see the Postgres CDC Pipeline Connector community documentation.
-
PolarDB-O Flink CDC vs. Postgres CDC
The PolarDB-O Flink CDC connector is built based on the Postgres CDC connector. For syntax and parameters, refer to the Postgres CDC documentation. However, the following key differences exist:
-
In the WITH clause, the 'connector' parameter must be set to the fixed value
polardbo-cdc. -
PolarDB Flink CDC is compatible with all versions of PolarDB for PostgreSQL, PolarDB for PostgreSQL (Compatible with Oracle) 1.0, and PolarDB for PostgreSQL (Compatible with Oracle) 2.0.
NoteIf you are using PolarDB for PostgreSQL, we recommend using the community Postgres CDC connector directly.
-
For
DATEtype columns in PolarDB for PostgreSQL (Compatible with Oracle) 1.0 and PolarDB for PostgreSQL (Compatible with Oracle) 2.0, the corresponding type in both the Flink SQL source and sink tables must be specified asTIMESTAMP. -
We recommend setting the
decoding.plugin.nameparameter topgoutput. Otherwise, databases with non-UTF-8 encoding might produce garbled characters during incremental parsing. For more information, see the community documentation.
Data type mapping
The mapping of data types between PolarDB for PostgreSQL and Flink is identical to that of community PostgreSQL, except for the DATE type. The complete mapping is as follows:
|
Source type |
Flink type |
|
SMALLINT |
SMALLINT |
|
INT2 |
|
|
SMALLSERIAL |
|
|
SERIAL2 |
|
|
INTEGER |
INT |
|
SERIAL |
|
|
BIGINT |
BIGINT |
|
BIGSERIAL |
|
|
REAL |
FLOAT |
|
FLOAT4 |
|
|
FLOAT8 |
DOUBLE |
|
DOUBLE PRECISION |
|
|
NUMERIC(p, s) |
DECIMAL(p, s) |
|
DECIMAL(p, s) |
|
|
BOOLEAN |
BOOLEAN |
|
DATE |
|
|
TIME [(p)] [WITHOUT TIMEZONE] |
TIME [(p)] [WITHOUT TIMEZONE] |
|
TIMESTAMP [(p)] [WITHOUT TIMEZONE] |
TIMESTAMP [(p)] [WITHOUT TIMEZONE] |
|
CHAR(n) |
STRING |
|
CHARACTER(n) |
|
|
VARCHAR(n) |
|
|
CHARACTER VARYING(n) |
|
|
TEXT |
|
|
BYTEA |
BYTES |
Examples
Source connector
This example shows how to use the PolarDB-O Flink CDC connector to synchronize the shipments table from the flink_source database to the shipments_sink table in the flink_sink database on a PolarDB for PostgreSQL (Compatible with Oracle) 2.0 cluster.
This example provides a basic demonstration of running the PolarDB-O Flink CDC connector on PolarDB for PostgreSQL (Compatible with Oracle). For production use, configure the connector parameters based on your business requirements by referring to the community Postgres CDC documentation.
-
Prerequisites
-
Prepare PolarDB for PostgreSQL (Compatible with Oracle)
-
On the PolarDB cluster purchase page, purchase a PolarDB for PostgreSQL (Compatible with Oracle) 2.0 cluster.
-
View the cluster primary endpoint. If the PolarDB cluster and your Realtime Compute for Apache Flink workspace are in the same virtual private cloud (VPC), you can use the private endpoint. Otherwise, you must apply for and use a public endpoint.
-
Configure an IP address whitelist for a cluster. Add the IP address of the Flink instance to the PolarDB cluster whitelist.
-
In the console, create the source database flink_source and the destination database flink_sink. For details, see Create a database.
-
Execute the following statements to create the shipments table in the flink_source database and insert data.
CREATE TABLE public.shipments ( shipment_id INT, order_id INT, origin TEXT, destination TEXT, is_arrived BOOLEAN, order_time DATE, PRIMARY KEY (shipment_id) ); ALTER TABLE public.shipments REPLICA IDENTITY FULL; INSERT INTO public.shipments SELECT 1, 1, 'test1', 'test1', false, now(); -
Execute the following statement to create the shipments_sink table in the flink_sink database.
CREATE TABLE public.shipments_sink ( shipment_id INT, order_id INT, origin TEXT, destination TEXT, is_arrived BOOLEAN, order_time TIMESTAMP, PRIMARY KEY (shipment_id) );
-
-
Prepare Realtime Compute for Apache Flink
-
Log on to the Realtime Compute console and purchase a Realtime Compute for Apache Flink instance. For more information, see Activate Realtime Compute for Apache Flink.
NoteWe recommend creating the Realtime Compute for Apache Flink workspace in the same Region and VPC as the PolarDB cluster. This allows you to use the PolarDB cluster's private primary endpoint for the connection.
-
Create a custom connector and upload the PolarDB-O Flink CDC package you built. Select debezium-json for Formats. For details, see Create a custom connector.
-
-
-
Create a Flink job
-
Log on to the Realtime Compute for Apache Flink console and create an SQL draft. For details, see Develop an SQL draft. Use the following Flink SQL code and replace the placeholders for your PolarDB cluster's primary endpoint, port, username, and password.
NoteThe DATE type in PolarDB for PostgreSQL (Compatible with Oracle) is 64-bit, whereas the DATE type in Flink SQL and most databases is 32-bit. Therefore, you must map
DATEcolumns in the source table to theTIMESTAMPtype in both the Flink SQL source and sink tables. Otherwise, the job fails with a type mismatch error, such as"java.time.DateTimeException: Invalid value for EpochDay (valid values -365243219162 - 365241780471): 1720891573000".CREATE TEMPORARY TABLE shipments ( shipment_id INT, order_id INT, origin STRING, destination STRING, is_arrived BOOLEAN, order_time TIMESTAMP, PRIMARY KEY (shipment_id) NOT ENFORCED ) WITH ( 'connector' = 'polardbo-cdc', 'hostname' = '<yourHostname>', 'port' = '<yourPort>', 'username' = '<yourUserName>', 'password' = '<yourPassWord>', 'database-name' = 'flink_source', 'schema-name' = 'public', 'table-name' = 'shipments', 'decoding.plugin.name' = 'pgoutput', 'slot.name' = 'flink' ); CREATE TEMPORARY TABLE shipments_sink ( shipment_id INT, order_id INT, origin STRING, destination STRING, is_arrived BOOLEAN, order_time TIMESTAMP, PRIMARY KEY (shipment_id) NOT ENFORCED ) WITH ( 'connector' = 'jdbc', 'url' = 'jdbc:postgresql://<yourHostname>:<yourPort>/flink_sink', 'table-name' = 'shipments_sink', 'username' = '<yourUserName>', 'password' = '<yourPassWord>' ); INSERT INTO shipments_sink SELECT * FROM shipments; -
Deploy and start the job.
In the top toolbar of the job editor, click Deploy.
In the left-side navigation pane, choose Operations Center > Deployments. In the job list, find the target job and click Start in the Actions column.
-
Test and verify the results.
-
After the job is deployed and in the running state, data from the shipments table is synchronized to the shipments_sink table in the flink_sink database.
SELECT * FROM public.shipments_sink;The following result is returned:
shipment_id | order_id | origin | destination | is_arrived | order_time -------------+----------+--------+-------------+------------+--------------------- 1 | 1 | test1 | test1 | f | 2024-09-18 05:45:08 (1 row) -
Execute DML statements on the shipments table in the flink_source database. The changes are synchronized in real time.
INSERT INTO public.shipments SELECT 2, 2, 'test2', 'test2', false, now(); UPDATE public.shipments SET is_arrived = true WHERE shipment_id = 1; DELETE FROM public.shipments WHERE shipment_id = 2; INSERT INTO public.shipments SELECT 3, 3, 'test3', 'test3', false, now(); UPDATE public.shipments SET is_arrived = true WHERE shipment_id = 3;The data in the shipments table is synchronized to the shipments_sink table in the flink_sink database.
SELECT * FROM public.shipments_sink;The following result is returned:
shipment_id | order_id | origin | destination | is_arrived | order_time -------------+----------+--------+-------------+------------+--------------------- 1 | 1 | test1 | test1 | t | 2024-09-18 05:45:08 3 | 3 | test3 | test3 | t | 2024-09-18 07:33:23 (2 rows)
-
-
Pipeline connector
This example shows how to use the PolarDB-O Flink CDC pipeline connector to synchronize the shipments1 and shipments2 tables from a PolarDB for PostgreSQL (Compatible with Oracle) 2.0 cluster. For debugging, the sink uses the Print connector. In a production environment, choose a suitable sink connector based on your business requirements.
This example provides a basic demonstration of running the PolarDB-O Flink CDC connector on PolarDB for PostgreSQL (Compatible with Oracle). For production use, configure the parameters based on your business requirements by referring to the community Postgres CDC Pipeline Connector documentation.
-
Prerequisites
-
Prepare PolarDB for PostgreSQL (Compatible with Oracle)
-
On the PolarDB cluster purchase page, purchase a PolarDB for PostgreSQL (Compatible with Oracle) 2.0 cluster.
-
View the cluster primary endpoint. If the PolarDB cluster and your Realtime Compute for Apache Flink workspace are in the same VPC, you can use the private endpoint. Otherwise, you must apply for and use a public endpoint.
-
Configure an IP address whitelist for a cluster. Add the IP address of the Flink instance to the PolarDB cluster whitelist.
-
In the console, create the source database flink_source. For details, see Create a database.
-
Execute the following statements to create the shipments1 and shipments2 tables in the flink_source database and insert data.
CREATE TABLE public.shipments1 ( shipment_id INT, order_id INT, origin TEXT, destination TEXT, is_arrived BOOLEAN, order_time DATE, PRIMARY KEY (shipment_id) ); ALTER TABLE public.shipments1 REPLICA IDENTITY FULL; INSERT INTO public.shipments1 SELECT 1, 1, 'test1', 'test1', false, now(); CREATE TABLE public.shipments2 ( shipment_id INT, order_id INT, origin TEXT, destination TEXT, is_arrived BOOLEAN, order_time DATE, PRIMARY KEY (shipment_id) ); ALTER TABLE public.shipments2 REPLICA IDENTITY FULL; INSERT INTO public.shipments2 SELECT 1, 1, 'test1', 'test1', false, now();
-
-
Prepare Realtime Compute for Apache Flink
Log on to the Realtime Compute console and purchase a Realtime Compute for Apache Flink instance. For more information, see Activate Realtime Compute for Apache Flink.
NoteWe recommend creating the Realtime Compute for Apache Flink workspace in the same Region and VPC as the PolarDB cluster. This allows you to use the PolarDB cluster's private primary endpoint for the connection.
-
-
Create a Flink job
-
Log on to the Realtime Compute for Apache Flink console and create a data ingestion draft. For details, see Flink CDC data ingestion. Use the following data ingestion configuration and replace the placeholders for your PolarDB cluster's primary endpoint, port, username, and password.
source: type: polardbo name: PolarDB Oracle Source hostname: '<yourHostname>' port: '<yourPort>' username: '<yourUserName>' password: '<yourPassWord>' tables: flink_source.public.shipments[12] decoding.plugin.name: pgoutput slot.name: pgtest sink: type: values name: values Sink print.enabled: true -
In the More section on the left, add the pipeline connector you built. In the More Configurations panel on the right, confirm that the engine version is
vvr-11.5-jdk11-flink-1.20and add the required dependency files in the Additional Dependency Files area. -
Deploy and start the job.
-
Click Deploy in the upper-right corner.
source: type: polardbo name: PolarDB Oracle Source hostname: xxx port: xxx username: xxx password: xxx tables: flink_source.public.shipments[12] decoding.plugin.name: pgoutput slot.name: pgtest sink: type: values name: values Sink print.enabled: true -
Go to the Deployments page and click Enable.
-
-
Test and verify the results.
-
After a deployment job runs successfully, its status is Running. You can find the CreateTableEvent and DataChangeEvent from the full data phase in the Job Log > Running Task Managers > Stdout log. On the deployment details page, click the Job Log tab, select Running Task Managers, and then click the Stdout tab to view the log output. Confirm that the output contains the following table creation events and data change events:
CreateTableEvent{tableId=public.shipments2, schema=columns={`shipment_id` INT NOT NULL,`order_id` INT,`origin` STRING,`destination` STRING,`is_arrived` BOOLEAN,`order_time` TIMESTAMP(6)}, primaryKeys=shipment_id, options=()} CreateTableEvent{tableId=public.shipments1, schema=columns={`shipment_id` INT NOT NULL,`order_id` INT,`origin` STRING,`destination` STRING,`is_arrived` BOOLEAN,`order_time` TIMESTAMP(6)}, primaryKeys=shipment_id, options=()} DataChangeEvent{tableId=public.shipments2, before=[], after=[1, 1, test1, test1, false, 2026-01-07T16:30:44], op=INSERT, meta=()} DataChangeEvent{tableId=public.shipments1, before=[], after=[1, 1, test1, test1, false, 2026-01-07T16:30:44], op=INSERT, meta=()} -
Execute DML statements on the shipments1 and shipments2 tables in the flink_source database. The changes are synchronized in real time.
INSERT INTO public.shipments1 SELECT 2, 2, 'test2', 'test2', false, now(); UPDATE public.shipments1 SET is_arrived = true WHERE shipment_id = 1; DELETE FROM public.shipments1 WHERE shipment_id = 2; INSERT INTO public.shipments1 SELECT 3, 3, 'test3', 'test3', false, now(); UPDATE public.shipments1 SET is_arrived = true WHERE shipment_id = 3; INSERT INTO public.shipments2 SELECT 2, 2, 'test2', 'test2', false, now(); UPDATE public.shipments2 SET is_arrived = true WHERE shipment_id = 1; DELETE FROM public.shipments2 WHERE shipment_id = 2; INSERT INTO public.shipments2 SELECT 3, 3, 'test3', 'test3', false, now(); UPDATE public.shipments2 SET is_arrived = true WHERE shipment_id = 3; -
You can find the DataChangeEvent for the incremental phase in the Job Logs > Running Task Managers > Stdout log:
DataChangeEvent{tableId=public.shipments1, before=[], after=[2, 2, test2, test2, false, 2026-01-07T16:44:50], op=INSERT, meta=()} DataChangeEvent{tableId=public.shipments1, before=[1, 1, test1, test1, false, 2026-01-07T16:30:44], after=[1, 1, test1, test1, true, 2026-01-07T16:30:44], op=UPDATE, meta=()} DataChangeEvent{tableId=public.shipments1, before=[2, 2, test2, test2, false, 2026-01-07T16:44:50], after=[], op=DELETE, meta=()} DataChangeEvent{tableId=public.shipments1, before=[], after=[3, 3, test3, test3, false, 2026-01-07T16:44:50], op=INSERT, meta=()} DataChangeEvent{tableId=public.shipments1, before=[3, 3, test3, test3, false, 2026-01-07T16:44:50], after=[3, 3, test3, test3, true, 2026-01-07T16:44:50], op=UPDATE, meta=()} DataChangeEvent{tableId=public.shipments2, before=[], after=[2, 2, test2, test2, false, 2026-01-07T16:44:50], op=INSERT, meta=()} DataChangeEvent{tableId=public.shipments2, before=[1, 1, test1, test1, false, 2026-01-07T16:30:44], after=[1, 1, test1, test1, true, 2026-01-07T16:30:44], op=UPDATE, meta=()} DataChangeEvent{tableId=public.shipments2, before=[2, 2, test2, test2, false, 2026-01-07T16:44:50], after=[], op=DELETE, meta=()} DataChangeEvent{tableId=public.shipments2, before=[], after=[3, 3, test3, test3, false, 2026-01-07T16:44:50], op=INSERT, meta=()} DataChangeEvent{tableId=public.shipments2, before=[3, 3, test3, test3, false, 2026-01-07T16:44:50], after=[3, 3, test3, test3, true, 2026-01-07T16:44:50], op=UPDATE, meta=()}
-
-