Skip to content

Read DuckLake VARIANT columns - #437

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

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

Conversation

@faysou

@faysou faysou commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Read shredded and unshredded Parquet VARIANT into Arrow Variant arrays. Prune files for
eligible ducklake_variant_get_int64 predicates when valid bounds for the exact path prove
the file cannot match. Keep files with unknown bounds and evaluate their rows.

VARIANT scan and pruning

flowchart LR
    Expr["Eligible integer path predicate"] --> Bounds{"Valid int64 bounds for this file and path?"}
    Bounds -->|Yes| Match{"Bounds can match?"}
    Bounds -->|Unknown| Decode["Read and normalize the physical VARIANT layout"]
    Match -->|Yes| Decode
    Match -->|No| Skip["Skip file"]
    Decode --> Evaluate["Evaluate rows as Arrow Variant"]
Loading

Verification

  • All-feature Clippy and all three VARIANT integration tests pass.
  • The DuckDB 1.5.5 oracle reads a mix of shredded and unshredded files. It checks values and
    confirms that the scan drops the disjoint shredded file and keeps the unshredded file.
  • Fresh DuckDB and SQLite catalogs expose the existing 12-column statistics table.
  • The hosted Linux job aborted in the row-ID history test. That test passed locally at the
    published commit. The hosted failure remains open.

Specification proof

DuckLake rule Implementation invariant Discriminating proof
DuckLake VARIANT type uses Parquet Variant Encoding with optional shredding. Normalize both physical layouts into the Arrow Variant extension type. The mixed-layout oracle reads the same nested values across the layouts.
Per-file VARIANT statistics identify a shredded field by its quoted path and type. Look up the exact quoted path and use bounds only for a matching int64 type. The oracle checks the stored path and bounds and prunes the file with bounds [0, 99] for a predicate requiring values at least 150.
Per-file VARIANT statistics are optional for a path. Treat missing, duplicate, malformed, mismatched, or inverted bounds as unknown. The oracle retains the unshredded file and evaluates its rows.

Reference implementation

DuckDB's DuckLake extension stores per-path type and bounds and parses quoted field names,
including doubled quotes. Variant statistics insertion,
Nested path parsing.

The reader normalizes DuckDB 1.5.5 file dictionaries with unsorted keys by clearing the sorted
flag for Arrow's dictionary lookup. The encoded values stay the same. The mixed-layout
oracle exercises the normalization and the integer pruning path.

- map VARIANT to Parquet extension storage and unshred physical files
- expose typed int64 access and prune from variant path statistics
- validate mixed layouts and nested paths against DuckDB 1.5.5
Recheck the hosted row-ID test after the archived CI binary passed locally.

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