PostgreSQL
The postgres connector reads and writes PostgreSQL tables over Npgsql. It runs on the universal
Arrow tier only: there is no native postgres_scanner scan wired up yet. Every read and write
streams through pz’s own batch path rather than a DuckDB COPY.
Connection
Section titled “Connection”warehouse: connector: postgres host: ${WAREHOUSE_HOST} database: ${WAREHOUSE_DB} user: ${WAREHOUSE_USER} password: ${WAREHOUSE_PASSWORD} entities: public.orders: read: {}| Key | Required | Default | Meaning |
|---|---|---|---|
host |
Yes | – | Server hostname. |
database |
Yes | – | Database name. |
port |
No | 5432 |
Server port. |
user |
No | – | Login role. |
password |
No | – | Login password. Always an ${ENV_VAR} reference, never a literal. |
ssl_mode |
No | – | Npgsql SSL mode string. |
connect_timeout_seconds |
No | driver default (15s) | Connection timeout, 1–3600 seconds. |
command_timeout_seconds |
No | driver default (30s) | Per-command timeout, 0–86400 seconds; 0 is unbounded. |
Read options
Section titled “Read options”| Key | Required | Default | Meaning |
|---|---|---|---|
query |
No | – | Replaces the generated SELECT entirely. Forbidden on a sync: {mode: cdc} entity. |
partition_column |
No | – | A numeric or date column to range-partition the read across. |
partitions |
No | 1 |
Partition count, 1-16. Only takes effect with partition_column. |
publication |
No | pz_{connection} |
The logical-replication publication name for sync: {mode: cdc} reads. |
poll_idle_timeout |
No | 5s |
How long a CDC read waits for new changes before yielding, once caught up. |
columns, sync, and retry under read: are the shared keys documented in the
connections.yml reference; rate_limit belongs on the connection.
A CDC read looks like this instead of a plain table read:
entities: public.orders: read: sync: mode: cdc publication: pz_orders_feedSee Capture changes with CDC for the publication and replication-slot setup this requires on the server.
Write options
Section titled “Write options”postgres takes no connector-specific write options. The target schema and table come from the
entity name: public.orders writes orders in schema public, and an unqualified name defaults
to schema public. It supports all three write strategies:
strategy: appendinserts.strategy: replaceswaps the table atomically.strategy: mergeupserts onON CONFLICT, keyed bykeys:, and can apply CDC deletes throughon_delete: deleteoron_delete: soft.
strategy, keys, on_delete, schema_policy, and retry under write: are the shared keys;
see the connections.yml reference.
Capabilities
Section titled “Capabilities”| Flag | Meaning |
|---|---|
ColumnPruning |
Reads project only the columns pz asks for. |
PredicatePushdown |
Reads push the compiled WHERE clause into the query. |
PartitionedRead |
Reads can split into multiple range partitions. |
Merge |
Writes support keyed upsert. |
Transactional |
A write commits atomically. |
ReplaceWrites |
Supports strategy: replace. |
BoundedWindow |
Pushes a watermark upper bound into the query. |
InclusiveWatermarkBound |
Accepts an inclusive lower watermark bound (cursor >= value). |
ApplyDeletes |
A merge write can apply CDC delete-key batches in the same transaction. |
ChangeCapture |
Supports sync: {mode: cdc} reads. |
NestedTypes |
Writes STRUCT, LIST, MAP and ARRAY columns (see Nested columns). |
query:andsync: {mode: cdc}are mutually exclusive on the same entity.- The session is pinned to UTC so watermark and window comparisons against a
timestamptzcursor stay exact; this is internal and needs no configuration.
Nested columns
Section titled “Nested columns”Since pz 0.22.0, a postgres array column reads as a DuckDB list (integer[] as INTEGER[], text[]
as VARCHAR[], and so on for every type this connector reads), with NULL elements kept. Before,
such a column failed as outside the type matrix.
An output can carry DuckDB’s nested types:
| DuckDB column | Postgres column |
|---|---|
LIST or ARRAY of a flat type (BIGINT[], VARCHAR[], DECIMAL(p,s)[], DATE[], TIMESTAMP[], INTEGER[3]…) |
an array of that type (bigint[], text[], numeric(38,9)[], date[], timestamptz[], integer[]), null elements kept |
STRUCT, MAP, or a LIST of nested values (STRUCT(...)[], INTEGER[][]) |
jsonb: a struct or map as an object (map keys as their text), a list as an array |
A missing target is created with these types. An existing target is checked against them under
schema_policy: fail_on_change, including an array’s element type (integer[] is not
bigint[]); a numeric array’s precision is not compared. VARIANT, UNION, and FLOAT or narrow
integers, on their own or inside a nested column, still fail with PZ0546: cast them in the
pipeline (payload::JSON::VARCHAR, qty::INTEGER).
Decimal values
Section titled “Decimal values”A decimal or numeric column up to 28 significant digits, with a scale of at most 28, writes
exactly. Since pz 0.12.0, a universal-tier write of a decimal(38,x) value beyond .NET
decimal’s range (more than 28 significant digits, or a scale above 28) fails with a permanent
error that names the column, instead of silently writing a wrong number. The Postgres driver
(Npgsql) writes numeric only from a .NET decimal, so it cannot carry such a value. Round or
cast the column in the pipeline before it reaches the sink, for example
cast(amount as decimal(28, 9)). SQL Server, NDJSON, CSV, and the partitioned Azure Blob, GCS, and
SFTP writers carry every digit.
Related
Section titled “Related”- Capture changes with CDC sets up the publication a CDC read needs.
- Incremental loads explains watermarks, sync modes, and merge together.
- connections.yml reference documents the shared read and write keys.
- Connectors compares every builtin connector’s capabilities at a glance.