Skip to main content
VeloDB Cloud 26.x is based on Apache Doris 4.x. See Version Mapping.

PostgreSQL CDC with Auto Table Creation

Use FROM POSTGRES ... TO DATABASE to replicate one or more PostgreSQL tables into an existing VeloDB Cloud database. The job creates a Unique Key table for each selected source table using its primary key. It delivers changes at least once. Choose SQL mapping when you need SQL expressions or row filters. For a guided workflow in the VeloDB Cloud Console, see Import from PostgreSQL.

SQL continuous load is experimental. Check Continuous Load Overview for warehouse availability.

Prerequisites​

  • Use a VeloDB Cloud warehouse with PostgreSQL streaming jobs enabled. Its executing cluster must be able to reach the PostgreSQL source and JDBC driver. See SaaS private connectivity or BYOC connectivity.
  • Enable logical replication on PostgreSQL and select tables with primary keys. The source user needs schema access, read access to the selected tables, and replication privileges. For AWS-managed sources, follow the Amazon RDS or Amazon Aurora setup guide.
  • Use a warehouse SQL user with LOAD_PRIV on the target database and CREATE_PRIV to create tables. Allow the job creator to alter target tables if the job will apply schema changes.

Create a streaming job​

In the warehouse SQL Editor or a connected SQL client, select the database that will own the job. This example copies existing rows from public.orders and public.customers and then consumes new changes from PostgreSQL. It assumes a source administrator created the publication warehouse_orders for both tables. Replace the source host, driver package, database names, table names, and credentials with values for your environment.

USE analytics;

CREATE JOB replicate_postgres
ON STREAMING
FROM POSTGRES (
"jdbc_url" = "jdbc:postgresql://<source-host>:5432/sales",
"driver_url" = "<approved-postgresql-driver>.jar",
"driver_class" = "org.postgresql.Driver",
"user" = "<sync-user>",
"password" = "<sync-password>",
"database" = "sales",
"schema" = "public",
"include_tables" = "orders,customers",
"publication_name" = "warehouse_orders",
"ssl_mode" = "require",
"offset" = "initial"
)
TO DATABASE analytics;

If a target table already exists, the job uses it. Verify its keys, column names, and types are compatible with the source before starting the job.

Check replication​

Inspect the job and its most recent tasks. After the initial snapshot finishes, query a known primary key in the target and compare it with the source. For a continuous job, also check a recent source change.

SELECT Name, Status, ErrorMsg
FROM jobs("type" = "insert") WHERE Name = 'replicate_postgres';

SELECT *
FROM tasks("type" = "insert") WHERE JobName = 'replicate_postgres';

Source parameters​

ParameterHow to use it
jdbc_url, database, schemaSpecify the reachable PostgreSQL endpoint, source database, and schema.
driver_url, driver_classUse a PostgreSQL JDBC package available to the warehouse or an approved HTTPS location. The driver class is org.postgresql.Driver. See JDBC driver requirements.
user, passwordSupply the PostgreSQL sync user's credentials.
include_tablesComma-separated source table names in the selected schema. Omitting both table filters selects every table in the schema. Job creation fails if any selected table lacks a primary key.
table.<source-table>.target_table, table.<source-table>.exclude_columnsOptionally rename a target table or omit a comma-separated list of non-key columns.
offsetinitial copies existing rows then streams changes. latest (default) starts with new changes. snapshot copies existing rows once.
snapshot_split_sizeNumber of rows per snapshot split. The default is 40,960 on Core 26.1.2 through 26.1.4.
snapshot_parallelismMaximum concurrent snapshot splits per task. Core 26.1.3 defaults to one. Core 26.1.4 chooses parallelism automatically within the service limit.
publication_name, slot_nameOptional names of an existing publication and a dedicated logical replication slot. Omit either name for the job to manage that resource. The publication must include every selected table. An inactive slot retains WAL on PostgreSQL.
ssl_mode, ssl_rootcertrequire encrypts the connection. Use verify-ca with ssl_rootcert to verify the source certificate against a trusted CA. Have an administrator register the CA in the job database under the streaming_job file catalog, then set ssl_rootcert to FILE:<file_name>.
schema_change_behaviorOn Core 26.1.4, evolve (default) applies supported column changes. ignore leaves the target schema under your control.

Target parameters​

The optional properties following TO DATABASE <target-db> apply to newly created tables and to writes.

ParameterHow to use it
table.create.properties.*Specify supported warehouse table properties for tables the job creates.
load.strict_modeEnable strict conversion checks when loading rows.
load.max_filter_ratioMaximum permitted fraction of filtered rows, from 0 to 1. Keep the default of 0 to treat filtered rows as errors. Investigate rejected rows if the job pauses.

Troubleshooting​

If the source connection fails, check DNS, security group rules, TLS settings, and driver availability from the executing cluster. If the publication check fails, verify its membership in pg_publication_tables in the source database and confirm the source user can read those tables. If writes fail, check the job creator's warehouse privileges and the PostgreSQL type mapping.

See Continuous Load for scheduling options and instructions to pause, resume, or drop the job. See CREATE STREAMING JOB for the full SQL syntax.