Skip to content

Conversation

@abhizer
Copy link
Contributor

@abhizer abhizer commented Dec 19, 2025

Fixes: #5263

Adds a new config mode to PostgresWriterConfig, which allows us to use a cdc mode. It is also possible to specify the operation and timestamp columns, by default, they are: __feldera_op and __feldera_ts.

  • __feldera_op: either i for insert operations, u for upserts or d for deletes.
  • __feldera_ts: the UTC timestamp when this record is being serialized.

For simplicity, in cdc mode, all insert, update and delete queries are the same insert query; this allows us to reuse code and avoid refactors.

Copilot AI review requested due to automatic review settings December 19, 2025 20:10
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds CDC (Change Data Capture) mode to the PostgreSQL output connector, allowing users to write all operations as INSERT operations into an append-only event log with metadata columns for operation type and timestamp.

Key changes:

  • Added PostgresWriteMode enum with Materialized (default) and Cdc modes
  • Added configuration options cdc_op_column and cdc_ts_column for CDC metadata columns
  • Modified SQL query generation to use INSERT for all operations in CDC mode
  • Added comprehensive test coverage for CDC mode across all operation types

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
docs.feldera.com/docs/connectors/sinks/postgresql.md Documents the new CDC mode and configuration options
crates/feldera-types/src/transport/postgres.rs Defines PostgresWriteMode enum and adds CDC configuration fields with validation
crates/adapters/src/integrated/postgres/test.rs Adds CDC test variants and PostgresTestStructCdc type for testing
crates/adapters/src/integrated/postgres/prepared_statements.rs Updates query generation to handle CDC mode INSERT operations
crates/adapters/src/integrated/postgres/output.rs Implements CDC metadata serialization and validation

@abhizer abhizer force-pushed the pg_event_log branch 3 times, most recently from a7459fa to 0a393dd Compare December 19, 2025 20:46
@abhizer abhizer requested a review from ryzhyk December 19, 2025 21:02
@abhizer abhizer self-assigned this Dec 19, 2025
@abhizer abhizer added the connectors Issues related to the adapters/connectors crate label Dec 19, 2025
Adds a new config `mode` to `PostgresWriterConfig`, which allows us to
use a `cdc` mode. It is also possible to specify the operation and
timestamp columns, by default, they are: `__feldera_op` and
`__feldera_ts`.

- `__feldera_op`: either `i` for insert operations, `u` for upserts or
  `d` for deletes.
- `__feldera_ts`: the UTC timestamp when this record is being serialized.

For simplicity, in `cdc` mode, all insert, update and delete queries are
the same insert query; this allows us to reuse code and avoid refactors.

Signed-off-by: Abhinav Gyawali <22275402+abhizer@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

connectors Issues related to the adapters/connectors crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[adapters] Postgres output connector: CDC mode

2 participants