Skip to content

add: schema evolution support (Postgres → Iceberg)#21

Merged
viggy28 merged 1 commit into
mainfrom
feature/schema-evolution
Apr 18, 2026
Merged

add: schema evolution support (Postgres → Iceberg)#21
viggy28 merged 1 commit into
mainfrom
feature/schema-evolution

Conversation

@viggy28

@viggy28 viggy28 commented Apr 18, 2026

Copy link
Copy Markdown
Owner

Automatically propagate ADD COLUMN, DROP COLUMN, ALTER TYPE (widening), and REPLICA IDENTITY changes from Postgres to Iceberg metadata.

Key changes:

  • Decoder diffs consecutive RelationMessages by column name to detect schema changes (ADD, DROP, TYPE_CHANGE, KEY_CHANGE)
  • Catalog evolves Iceberg schema with stable field IDs (allocated from lastColumnID, not positional) and sets initial-default for ADD with DEFAULT
  • Writer flushes old-schema buffer before evolving, then updates field IDs
  • On restart, writer reconciles WAL columns against Iceberg metadata to detect schema drift that occurred while stopped
  • Second (non-replication) Postgres connection queries pg_attrdef for column default expressions
  • Type widening validated against allowlist (int→long, float→double)

Closes #4

What

Brief description of the change.

Why

What problem does this solve?

How to test

Steps to verify this change works correctly.

Automatically propagate ADD COLUMN, DROP COLUMN, ALTER TYPE (widening),
and REPLICA IDENTITY changes from Postgres to Iceberg metadata.

Key changes:
- Decoder diffs consecutive RelationMessages by column name to detect
  schema changes (ADD, DROP, TYPE_CHANGE, KEY_CHANGE)
- Catalog evolves Iceberg schema with stable field IDs (allocated from
  lastColumnID, not positional) and sets initial-default for ADD with DEFAULT
- Writer flushes old-schema buffer before evolving, then updates field IDs
- On restart, writer reconciles WAL columns against Iceberg metadata to
  detect schema drift that occurred while stopped
- Second (non-replication) Postgres connection queries pg_attrdef for
  column default expressions
- Type widening validated against allowlist (int→long, float→double)

Closes #4

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@viggy28
viggy28 merged commit 476d6b1 into main Apr 18, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Schema evolution support (ALTER TABLE propagation)

1 participant