Skip to content

Write encrypted DuckLake Parquet files - #439

Open
faysou wants to merge 2 commits into
datafusion-contrib:mainfrom
faysou:ducklake-encryption-write-pr
Open

faysou wants to merge 2 commits into
datafusion-contrib:mainfrom
faysou:ducklake-encryption-write-pr

Conversation

@faysou

@faysou faysou commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Encrypt each new Parquet data or delete file when the catalog's encrypted option is
true. Buffered, streaming, partitioned, flush, and compaction writes generate a fresh key per
physical file and store it in the file's catalog commit. Builds without the encryption feature
refuse operations that would write Parquet to an encrypted catalog.

Encrypted Parquet write

flowchart LR
    Write["Write, flush, delete, or compact"] --> Key["Generate a fresh key per Parquet file"]
    Key --> File["Write encrypted Parquet"]
    File --> Stats["Read footer statistics using that key"]
    Stats --> Commit["Commit file metadata and encryption key"]
    Commit --> Read["DuckDB opens the catalog and decrypts the file"]
Loading

Verification

  • All-feature Clippy passes.
  • encrypted_writes_flush_delete_and_rewrite exercises flush, positional delete, and
    compaction in a SQLite-backed catalog. It checks distinct catalog keys and verifies that
    reading without a key fails. DuckDB 2.0.1 reads the remaining values, 7 and 13.
  • Seven tests pass in an isolated SQLite harness built without encryption.

Specification proof

DuckLake rule Implementation invariant Discriminating proof
DuckLake encryption uses Parquet Modular Encryption. Encrypt the physical Parquet file, with a separately generated key for each file. The SQLite round-trip rejects a plain Parquet read and checks distinct keys.
Data file metadata and Delete file metadata store the file's key. Commit the key with the file row for data, positional deletes, and rewritten files. DuckDB 2.0.1 reads the crate-written catalog and returns the exact surviving rows.

Reference implementation

DuckDB's DuckLake extension supplies encryption configuration to Parquet COPY and uses an
encryption key when writing positional deletes. This PR applies the same catalog contract
to the Rust writer and records each file's key when it publishes the file.
Parquet COPY encryption configuration,
Delete write encryption key.

The DuckDB 2.0.1 round-trip also exercises the encrypted DataPageV2 reader fix.
DuckDB DataPageV2 fix.

- Honor DuckLake's Parquet V1 default and reject encrypted V2
- Generate and persist a fresh PME key for every output file
- Verify raw-key failure, compaction re-keying, and DuckDB reads
Start a new CI run after the hosted macOS job was canceled.

This branch has not been deployed

No deployments
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.

1 participant