PostgreSQL
VeloDB Cloud provides the following ways to load data from PostgreSQL:
- Loading PostgreSQL data via JDBC Catalog
VeloDB Cloud uses JDBC Catalog to map PostgreSQL as an external catalog, allowing direct SQL queries against PostgreSQL data. Combined with INSERT INTO or CREATE TABLE AS SELECT, this is suitable for one-time migration or periodic batch loading.
- Continuously syncing PostgreSQL data via Streaming Job
VeloDB Cloud uses Streaming Job to continuously sync full and incremental data from PostgreSQL to VeloDB Cloud. By integrating Flink CDC reading capability, VeloDB Cloud keeps the job running, reads WAL from PostgreSQL and writes it to VeloDB Cloud tables with delivery semantics determined by the selected mode. Two modes are supported: SQL Mapping Sync and Auto Table Creation Sync. Available in the VeloDB Core 26.1 series (Public Preview).
- Loading PostgreSQL data via Flink Doris Connector
Use Flink Doris Connector together with Flink Postgres CDC for real-time synchronization. This is suitable for scenarios that require additional Flink stream processing logic. The connector also provides a one-click full-database synchronization tool. For details, see Flink Doris Connector.
- Loading PostgreSQL data via third-party tools
Data integration tools such as DataX, SeaTunnel, and CloudCanal offer source-specific transfer options. Batch and CDC support vary by tool and connector. Check the chosen tool before syncing data from PostgreSQL to VeloDB Cloud.
In most cases, you can use JDBC Catalog directly for one-time data migration. When continuous full + incremental synchronization is required, Streaming Job is recommended.
Before you begin
For a guided full and incremental import, see Import from PostgreSQL. The console configures a native Streaming Job for supported sources and deployments. Use JDBC Catalog for batch copies, Streaming Job SQL for direct configuration, or an external Flink pipeline for custom stream processing. See Load Overview for how these methods relate.
Use a running warehouse and ensure it can reach the source database. Replace sample source hosts, credentials, and JDBC driver URLs. Use a source account with the required read or replication privileges and a warehouse SQL user with the required catalog, load, and create privileges. For SQL driver configuration, use a JDBC driver URL accessible to the warehouse and permitted by the service. Do not upload a JAR to a managed host. The linked catalog and import guides describe source-specific prerequisites.
Native MySQL and PostgreSQL CDC Streaming Jobs are available in the VeloDB Core 26.1 series, which is in Public Preview. Check your warehouse version and the selected mode before using the examples.
Load PostgreSQL data via JDBC catalog
Use JDBC Catalog to map PostgreSQL as an external catalog, then use INSERT INTO or CREATE TABLE AS SELECT to load data. For detailed syntax, see JDBC PostgreSQL Catalog.
Step 1: prepare data in PostgreSQL
CREATE TABLE public.students (
id INT PRIMARY KEY,
name VARCHAR(64),
age INT
);
INSERT INTO public.students VALUES (1, 'Emily', 25), (2, 'Bob', 30);
Step 2: create a catalog in your warehouse
CREATE CATALOG pg_catalog PROPERTIES (
"type" = "jdbc",
"user" = '<source-user>',
"password" = '<password>',
"jdbc_url" = "jdbc:postgresql://<postgresql-host>:5432/postgres",
"driver_url" = "<jdbc-driver-url>",
"driver_class" = "org.postgresql.Driver"
);
Step 3: create the target table in your warehouse
CREATE DATABASE IF NOT EXISTS doris_db;
CREATE TABLE doris_db.students (
id INT,
name VARCHAR(64),
age INT
)
UNIQUE KEY(id)
DISTRIBUTED BY HASH(id) BUCKETS 1;
Step 4: load data with INSERT INTO
INSERT INTO doris_db.students
SELECT id, name, age FROM pg_catalog.postgres.public.students;
If the target table does not exist yet, you can also use CREATE TABLE AS SELECT to create the table and load data in one step:
CREATE TABLE doris_db.students
AS
SELECT * FROM pg_catalog.postgres.public.students;
Step 5: verify loaded data
SELECT * FROM doris_db.students;
+----+-------+------+
| id | name | age |
+----+-------+------+
| 1 | Emily | 25 |
| 2 | Bob | 30 |
+----+-------+------+
Continuously sync PostgreSQL data via Streaming Job
Streaming Job continuously reads PostgreSQL WAL via Flink CDC and writes it to VeloDB Cloud. Two modes are supported:
- PostgreSQL CDC with Auto Table Creation: VeloDB Cloud creates downstream tables automatically on first sync (use
include_tablesto sync one, several, or all tables). Provides at-least-once semantics. - PostgreSQL CDC with SQL Mapping: target table must be pre-created in your warehouse. Supports flexible column mapping, data transformation, and exactly-once semantics.
Limitations
- Source tables must have primary keys. Auto Table Creation Sync creates Unique Key target tables. For SQL Mapping Sync, pre-create a compatible Unique Key target table.
- Load privilege is required. Auto Table Creation Sync also needs Create privilege when auto-creating downstream tables on first run.
- Available in the VeloDB Core 26.1 series (Public Preview).
Prerequisites
Before submitting a Streaming Job, logical replication (wal_level=logical) must be enabled on the PostgreSQL side and the user must be granted the corresponding REPLICATION privileges. For environment-specific setup steps, see:
- Amazon RDS PostgreSQL Setup Guide
- Amazon Aurora PostgreSQL Setup Guide
- See Continuous Load Overview for notes and required permissions of each mode.
Operation example: auto table creation sync
auto table creation sync
Auto Table Creation Sync uses the FROM POSTGRES ... TO DATABASE ... syntax. The target is a VeloDB Cloud database, and the downstream tables are automatically created on first sync.
Step 1: prepare data in PostgreSQL
CREATE TABLE public.students (
id INT PRIMARY KEY,
name VARCHAR(64),
age INT
);
INSERT INTO public.students VALUES (1, 'Emily', 25), (2, 'Bob', 30);
Step 2: create the target database in your warehouse
Auto Table Creation Sync does not require pre-creating tables, but the target database that hosts them must exist:
CREATE DATABASE IF NOT EXISTS doris_db;
Step 3: create a Streaming Job
The example below uses include_tables to sync only the students table (multiple tables can be comma-separated; leave empty to sync the whole database):
CREATE JOB pg_db_sync
ON STREAMING
FROM POSTGRES (
"jdbc_url" = "jdbc:postgresql://<postgresql-host>:5432/postgres",
"driver_url" = "<jdbc-driver-url>",
"driver_class" = "org.postgresql.Driver",
"user" = '<source-user>',
"password" = '<password>',
"database" = "postgres",
"schema" = "public",
"include_tables" = "students",
"offset" = "initial"
)
TO DATABASE doris_db;
Step 4: check job status
SELECT * FROM jobs("type"="insert") WHERE ExecuteType = "STREAMING";
Step 5: inspect auto-created VeloDB Cloud tables and loaded data
SHOW TABLES FROM doris_db;
SELECT * FROM doris_db.students;
For more common operations and full parameter reference, see PostgreSQL CDC with Auto Table Creation.
Operation example: SQL mapping sync
SQL mapping sync
Step 1: prepare data in PostgreSQL
CREATE TABLE public.students (
id INT PRIMARY KEY,
name VARCHAR(64),
age INT
);
INSERT INTO public.students VALUES (1, 'Emily', 25), (2, 'Bob', 30);
Step 2: create the target table in your warehouse
SQL Mapping Sync requires the target table to exist beforehand:
CREATE DATABASE IF NOT EXISTS doris_db;
CREATE TABLE doris_db.students (
id INT,
name VARCHAR(64),
age INT
)
UNIQUE KEY(id)
DISTRIBUTED BY HASH(id) BUCKETS 1;
Step 3: create a Streaming Job
Use CREATE STREAMING JOB with the INSERT INTO ... SELECT * FROM cdc_stream(...) syntax:
CREATE JOB pg_students_sync
ON STREAMING
DO
INSERT INTO doris_db.students
SELECT * FROM cdc_stream(
"type" = "postgres",
"jdbc_url" = "jdbc:postgresql://<postgresql-host>:5432/postgres",
"driver_url" = "<jdbc-driver-url>",
"driver_class" = "org.postgresql.Driver",
"user" = '<source-user>',
"password" = '<password>',
"database" = "postgres",
"schema" = "public",
"table" = "students",
"offset" = "initial"
);
Step 4: check job status
SELECT * FROM jobs("type"="insert") WHERE ExecuteType = "STREAMING";
Step 5: verify loaded data
SELECT * FROM doris_db.students;
For more common operations (pause, resume, delete, check task, etc.) and full parameter reference, see PostgreSQL CDC with SQL Mapping.