Repository navigation
Conversation
faysou
requested review from
anoop-narang,
shefeek-jinnah and
zfarrell
as code owners
October 5, 2026 20:26
faysou
force-pushed
the
ducklake-catalog-ddl-sql-pr
branch
2 times, most recently
from
October 5, 2026 21:38
da178d5 to
a9d258a
Compare
faysou
force-pushed
the
ducklake-catalog-ddl-sql-pr
branch
from
November 23, 2026 15:00
a9d258a to
1819dee
Compare
…te_ducklake_sql Handle the four statements through execute_ducklake_sql on SQLite and the PostgreSQL multicatalog writer. A rename keeps the table's stable id and writes a second ducklake_table row, so table_id is no longer the row primary key; a migration drops the old key on existing catalogs. A schema drop is refused while live tables, views, or macros remain. Each statement is one snapshot that bumps schema_version and records its change in the snapshot ledger. SQLite snapshots copy the preceding allocator watermarks, and a new schema takes an explicit id, so DuckDB reads catalogs it created.
faysou
force-pushed
the
ducklake-catalog-ddl-sql-pr
branch
from
November 23, 2026 15:52
1819dee to
0480600
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add
CREATE SCHEMA,DROP SCHEMA,DROP TABLE, andALTER TABLE ... RENAME TOtoexecute_ducklake_sql. SQLite and experimental multicatalog PostgreSQL apply each effectiveoperation as one metadata-only transaction;
IF EXISTSandIF NOT EXISTSno-ops create nosnapshot, and non-empty schema drops fail without changing the head.
Table rename now writes a new
ducklake_tableversion with the same table ID, schema, path, andoptional UUID. The explicit SQLite layout migration removes a legacy table primary key
without changing its table IDs. Drop ends the live table and its dependent metadata.
Catalog DDL flow
flowchart LR SQL["Catalog DDL SQL"] --> Parse["DuckDB dialect parser"] Parse --> Writer["MetadataWriter catalog operation"] Writer --> Lock["SQLite transaction or PostgreSQL catalog lock"] Lock --> Snapshot["One schema-changing snapshot"] Snapshot --> Version["Version schema or table metadata"] Version --> Readers["Historical and current DataFusion or DuckDB readers"]Supported contract
MetadataWriter::create_schemaIF NOT EXISTS.MetadataWriter::drop_schemaIF EXISTStarget.MetadataWriter::drop_tableMetadataWriter::rename_tableexecute_ducklake_sqlSqliteMetadataWriter::migrate_to_official_layoutbefore the first rename ifducklake_table.table_idis a primary key.Catalog layout
migrate_multicatalog_schema. Stop older processes first. Layout version 3 preserves theidentity sequence and enforces one live row per table ID.
ducklake_table.table_idneedsSqliteMetadataWriter::migrate_to_official_layoutbefore a rename. Newly created catalogs alreadysupport versioned table rows.
Commit and branch
faysou:ducklake-catalog-ddl-sql-pr.Verification
cargo fmt --all -- --checkand all-feature Clippy pass.and drop, and a live PostgreSQL migration followed by a rename with the same table ID.
migration also passes the test that holds locks on every table it does not need to change.
Specification proof
CREATE SCHEMAinserts a versioned schema with a fresh ID.schema_version, and recordscreated_schemain one transaction; PostgreSQL performs the equivalent catalog-scoped commit.IF NOT EXISTS; the official DuckDB oracle sees exactly one Rust-createdrust_schema.DROP SCHEMAends the schema row and permits only empty schemas.end_snapshotonly after validation.IF EXISTSis a no-op.DROP TABLEends the table, partition info, columns, column tags, data files, delete files, and table tags.table_id, schema, path, and optional UUID.archived_events; pre-rename lookup resolves onlyevents; raw SQLite and PostgreSQL rows have the same exact table ID and adjacent bounds.ducklake_tabledefines table visibility bybegin_snapshotand exclusiveend_snapshot.42, UUID, schema, name, and begin snapshot while provingtable_idis no longer the row primary key.schema_versionfor schema changes.Reference implementation
Schema creation and drop dispatch match
ducklake_catalog.cpp,including no-op conflict handling and dependency validation. The branch now matches the
extension's
schema emptiness check
by rejecting a drop while a live table, view, or macro remains. Table rename keeps the stable
identity as in
ducklake_table_entry.cpp,and the seven stable tombstones match
DropTables.The branch deliberately omits
CASCADE: the stable specification permitsDROP SCHEMAonly foran empty schema.