Repository navigation
Conversation
Commits an Iceberg dataset to LFS for future testing. This is the same approach we use today for parquet files, but for Iceberg in this case, the upper PR in this stack will use it for integration testing. --- <sub>Stack created with <a href="https://github.com/github/gh-stack">GitHub Stacks CLI</a> • <a href="https://gh.io/stacks-feedback">Give Feedback 💬</a></sub>
Introduces the empty `datafusion-distributed-iceberg` crate, its dependency set, and the corresponding lockfile updates. This is the first layer of the Iceberg integration stack. The implementation follows in datafusion-contrib#595.
Closes datafusion-contrib#600 > [!NOTE] > The PR is large because it contains a lot of boilerplate for a basic Iceberg integration, but it was crafted by hand, and it contains just whatever is minimal to get some tests e2e running Adds a very basic Iceberg integration as a new crate that depends on `datafusion`, `datafusion-distributed` and `iceberg-rust`. This is mostly a rewrite of https://github.com/apache/iceberg-rust/tree/main/crates/integrations/datafusion, with a few exceptions for helpers like expression transpilation. It heavily relies on `WorkUnitFeed`s for streaming `FileScanTask`s at runtime, following a pattern that looks like this today in single-node: ```rust ┌────────────────────────────────────────────┐ │ IcebergDataSource │ │ │ │┌──────────────────────────────────────────┐│ ││ IcebergWorkUnitFeed ││ ││┌────────────┐┌────────────┐┌────────────┐││ │││ Feed 0 ││ Feed 1 ││ Feed 2 │││ ││└──────┬─────┘└──────┬─────┘└──────┬─────┘││ │└───────┼─────────────┼─────────────┼──────┘│ │ .─────▼─────. .─────▼─────. .─────▼─────. │ │ (FileScanTask (FileScanTask (FileScanTask )│ │ .───────────. `─────┬─────' .───────────. │ │ (FileScanTask ) │ (FileScanTask )│ │ `─────┬─────' │ .───────────. │ │ │ │ (FileScanTask )│ │ │ │ `─────┬─────' │ │ │ │ │ │ │ ┌──────▼─────┐┌──────▼─────┐┌──────▼─────┐ │ │ │Partition 0 ││Partition 1 ││Partition 2 │ │ │ │ArrowReader ││ArrowReader ││ArrowReader │ │ │ └──────┬─────┘└──────┬─────┘└──────┬─────┘ │ │ │ │ │ │ │ .─────▼─────. │ .─────▼─────. │ │ ( RecordBatch ).─────▼─────.( RecordBatch )│ │ `─────┬─────'( RecordBatch ).───────────. │ │ │ `─────┬─────'( RecordBatch )│ │ │ │ `───────────' │ └────────┼─────────────┼─────────────┼───────┘ ▼ ▼ ▼ ``` And that will look like this once distribution is supported: ```rust ┌ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ Coordinating Context │ │ ┌────────────────────────────────────────────────────────────────────────────────────────┐│ ││ IcebergWorkUnitFeed │ │┌─────────────┐┌─────────────┐┌────────────┐┌────────────┐┌─────────────┐┌─────────────┐││ │││ Feed 0 ││ Feed 1 ││ Feed 2 ││ Feed 3 ││ Feed 4 ││ Feed 5 ││ │└──────┬──────┘└─────┬───────┘└────┬───────┘└───────┬────┘└───────┬─────┘└──────┬──────┘││ └└───────┼─────────────┼─────────────┼────────────────┼─────────────┼─────────────┼───────┴ .─────▼─────. .─────▼─────. .─────▼─────. .─────▼─────. .─────▼─────. .─────▼─────. (FileScanTask (FileScanTask (FileScanTask ) (FileScanTask (FileScanTask (FileScanTask ) .───────────. `─────┬─────' .───────────. `─────┬─────' .───────────. `─────┬─────' (FileScanTask ) │ (FileScanTask ) │ (FileScanTask ) │ `─────┬─────' │ .───────────. │ `───────────' │ │ │ (FileScanTask ) │ │ │ Worker 0 │ │ `─────┬─────' │ │ │ Worker 1 ┌ ─ ─ ─ ─ ┼ ─ ─ ─ ─ ─ ─ ┼ ─ ─ ─ ─ ─ ─ ┼ ─ ─ ─ ┐┌ ─ ─ ─ ┼ ─ ─ ─ ─ ─ ─ ┼ ─ ─ ─ ─ ─ ─ ┼ ─ ─ ─ ─ ┐ ┌───────┼─────────────┼─────────────┼───────┐┌───────┼─────────────┼─────────────┼───────┐ │ │ │ IcebergD│taSource │ ││ │ IcebergD│taSource │ │ │ │ │ │ │ ││ │ │ │ │ │ │┌──────▼─────┐┌──────▼─────┐┌──────▼─────┐ ││┌──────▼─────┐┌──────▼─────┐┌──────▼─────┐ │ │ ││Partition 0 ││Partition 1 ││Partition 2 │ │││Partition 0 ││Partition 1 ││Partition 2 │ │ │ ││ArrowReader ││ArrowReader ││ArrowReader │ │││ArrowReader ││ArrowReader ││ArrowReader │ │ │ │└──────┬─────┘└──────┬─────┘└──────┬─────┘ ││└──────┬─────┘└──────┬─────┘└──────┬─────┘ │ │ │ │ │ │ ││ │ │ │ │ │ │ .─────▼─────. │ .─────▼─────. ││ │ ▼ ▼ │ │ │( RecordBatch ).─────▼─────.( RecordBatch )││ .─────▼─────. .───────────. .───────────. │ │ │ `─────┬─────'( RecordBatch ).───────────. ││( RecordBatch ( RecordBatch ) RecordBatch )│ │ │ │ `─────┬─────'( RecordBatch )││ `─────┬─────' `───────────' `─────┬─────' │ │ │ │ │ `───────────' ││ │ ( RecordBatch ) │ │ │ │ │ │ │ ││ │ `─────┬─────' │ │ │ └───────┼─────────────┼─────────────┼───────┘└───────┼─────────────┼─────────────┼───────┘ │ ▼ ▼ ▼ ││ ▼ ▼ ▼ │ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ``` However, this PR just adds a very basic integration that includes: - Basic plumbing for `TableProvider` and `TableProviderFactory` implementations, very similar to what https://github.com/apache/iceberg-rust/tree/main/crates/integrations/datafusion has today on this front - An `IcebergWorkUnitFeed` implementation that streams `FileScanTask`s messages at execution time as new files are discovered - An `IcebergDataSource` that reads the `FileScanTask` streams, executing the tasks and yielding Arrow `RecordBatches`. - Integration tests, for existing functionality and future one. It's still laking: - Any kind of distribution - Any kind of [de]serialization for `FileScanTask`s and `IcebergDataSource`s - No filter pushdowns - No sort pushdowns - No benchmarks - No sense of data partitioning --- <sub>Stack created with <a href="https://github.com/github/gh-stack">GitHub Stacks CLI</a> • <a href="https://gh.io/stacks-feedback">Give Feedback 💬</a></sub>
Tackles datafusion-contrib#608. Added runtime statistics that can be extracted from the current snapshot metadata. `total-records` and `total-files-size` which are being used in the `partition_statistics` function.
…#690) ## Summary An existing snapshot may legally omit total-records or total-files-size because they are optional snapshot summary fields. Missing statistics mean unknown, not zero. Therefore they should map to Precision::Absent, while valid values remain Precision::Exact(value). - A table with no snapshot is genuinely empty, so Exact(0) is correct. - report absent statistics when an existing snapshot omits `total-records` or `total-files-size` - report malformed snapshot summary values as absent instead of exact zero [Iceberg defines these snapshot summary metrics as optional.](https://iceberg.apache.org/spec/#optional-snapshot-summary-fields) Treating a missing metric as exact zero can produce incorrect metadata. ## Validation - `cargo fmt --all -- --check` - `cargo test -p datafusion-distributed-iceberg` - `cargo clippy -p datafusion-distributed-iceberg --all-targets -- -D warnings` *(blocked by the inherited `collapsible_if` warning in `iceberg/tests/statistics.rs`)* - `git diff --check origin/iceberg-0.10...HEAD`
## Summary Implements a wire representation for Iceberg `FileScanTask` work units so they can be serialized by the distributed work-unit transport. The implementation uses a protobuf envelope containing a MessagePack payload. It validates file ranges, projected field IDs, partition metadata, and canonical partition-value encodings while reconstructing the Iceberg task on the consumer. Closes datafusion-contrib#604. ## Commits The PR is split into two independently working commits so the context-reuse trade-off is easy to review: 1. `d08b3b1` — adds a stateless, production-ready encoder where every work unit contains its complete task context. 2. `93a76dd` — adds per-feed context reuse and the stateful decoder described below. ## Shared-context decoder Iceberg file tasks commonly repeat the same schema, projection, predicate, partition spec, name mapping, and case-sensitivity setting. Although several of those values use `Arc` in memory, serializing an `Arc<T>` still writes the complete `T` for every work unit. The second commit assigns repeated contexts an ID. The first work unit in each partition feed defines the context, and later work units reference it by ID. A decoder owned by that partition stream retains the definitions while reconstructing tasks. State is isolated per feed and per query; it is not shared across partitions, distributed tasks, or queries. This reduces repeated serialization, allocation, and network bytes at the cost of an order-dependent per-feed protocol. A distributed transport test verifies that context definitions and references remain ordered through coordinator batching, partition routing, and gRPC transport. ## Taxi fixture measurement Using the seven real file scan tasks from the checked-in taxi table, routed over its four partition feeds: - repeated complete context: **6,552 bytes** - shared per-feed context: **4,425 bytes** - reduction: **2,127 bytes (32.5%)** This is a deterministic encoded-size regression test, not a runtime benchmark. The taxi fixture is conservative because it has only seven files spread over four feeds; larger tables normally reuse each feed context across many more files. ## Validation - `cargo test -p datafusion-distributed-iceberg` - `cargo test --features integration --test work_unit_feed` - targeted Clippy checks for the Iceberg library and distributed work-unit integration test - formatting and diff checks
Follow-up to datafusion-contrib#676 (closes datafusion-contrib#681) What was changed/added: 1. Statistics are being computed once at the very beginning of the scan and not recomputed 2. Everything is being computed from `ManifestList` -> `ManifestFile` -> `Manifest` (from where we get `DataFile` information). Now we are getting datafile level stats directly by mapping `field-ids` to actual columns in `.parquet` files. 3. Casting from iceberg's `Datum`
) Tests can supply complete Iceberg table metadata, explicit table options, and in-memory fixture files through `IcebergTestHarness::builder()`. - `with_table_metadata` accepts native Iceberg metadata without reconstructing its IDs, schemas, or snapshot history. - `with_table_option` replaces duplicated registration SQL in the selected-snapshot and invalid-snapshot-ID tests. - `with_file(uri, bytes)` overrides a fixture file, including manifests and manifest lists. Explicit files take precedence over generated metadata; unmodified paths fall back to the checked-in taxi fixture. An empty-table registration test verifies raw metadata override behavior. `build()` now constructs the session and registers the table directly; there is no intermediate `create()` helper. The harness remains usable without distributed integration features. Shared fixture helpers expose only the original taxi metadata and a native metadata builder starting before the first snapshot. Snapshot recipes stay test-local. The duplicated missing-summary JSON fixture is removed. Rebased onto `iceberg-0.10` at `6507bf8`, including merged datafusion-contrib#687. The table-options cleanup and file-override support are separate commits. Test-case consolidation is intentionally kept in an independent PR. Validation on datafusion-contrib#700 at `bb3872e`: - `cargo test -p datafusion-distributed-iceberg --locked` — 90 tests passed, including the doctest - `cargo clippy -p datafusion-distributed-iceberg --all-targets --locked -- -D warnings` - `cargo fmt --all -- --check` - `git diff --check`
…trib#716) Reapplies the reviewed and merged changes from datafusion-contrib#703 to the intended base, `iceberg-0.10`. datafusion-contrib#703 was still targeting `codex/iceberg-runtime-metadata` when it merged, after datafusion-contrib#700 had already merged into `iceberg-0.10`. Consequently, its codec-test improvements landed only on the old topic branch. This PR cherry-picks datafusion-contrib#703's merge commit (`eafc234`) onto `iceberg-0.10`, without additional code changes. It retains the original 15-line diff in `iceberg/src/codec.rs`: explicit storage properties, including a quote-containing value, and assertions that those properties survive the codec round trip. Validation: - `cargo test -p datafusion-distributed-iceberg --locked --lib roundtrips_data_source_plan` — passed. - `cargo fmt --all -- --check` and `git diff --check` passed. Targets `iceberg-0.10` directly; it does not depend on the separate reapplication of datafusion-contrib#704.
Reapplies the reviewed and merged changes from datafusion-contrib#704 to the intended base, `iceberg-0.10`. datafusion-contrib#704 was still targeting `codex/iceberg-runtime-metadata` when it merged, after datafusion-contrib#700 had already merged into `iceberg-0.10`. Consequently, the estimator and harness changes landed only on the old topic branch. This PR cherry-picks datafusion-contrib#704's merge commit (`d3ba554`) onto `iceberg-0.10`. There are no additional code changes; the resulting tree is identical to datafusion-contrib#704's final head (`12e1512`). Includes the source-statistics-based task estimator, explicit estimation tests, distributed execution coverage, and the private-context harness with `configure_session(...)`. Validation: - `cargo test -p datafusion-distributed-iceberg --features integration --locked --test desired_task_count` — all 9 tests passed. - `cargo fmt --all -- --check` and `git diff --check` passed. - Verified exact tree equality with datafusion-contrib#704's final head. Targets `iceberg-0.10` directly; it does not depend on the separate reapplication of datafusion-contrib#703.
…sion-contrib#705) ## Less test code, stronger statistics coverage Based directly on `iceberg-0.10` at `f9340ef`, including merged datafusion-contrib#715 and datafusion-contrib#716. “Before” refers to that base. Only `iceberg/tests/statistics.rs` changes, with a net reduction of 24 lines. | Test / edge case | Before | After | |---|---|---| | Row count and full-scan byte size | Separate enabled/disabled test bodies | Ordinary named tests share assertions and retain both modes | | Full-schema column statistics | Vector length only, in another pair of tests | Complete expected vector: populated metrics and unknown columns | | Reordered projection / nonconsecutive selected field IDs | Projected vector length and row count | Exact association of metrics with reordered columns using IDs 4, 1, and 5 | | Null-count aggregation across files | **None** | Exact sum of 5 | | Column-size aggregation across files | **None** | Inexact sums of 400 and 600 | | Min/max bounds and scalar types | **None** | Int32 and Int64 bounds checked with their precision; opposing extrema order exercises both updating and retaining bounds | | One file missing a column's null count | **None** | Aggregate stays `Absent`, rather than treating missing as zero | | Entirely missing column metrics | Only an all-empty-metrics fixture | Unknown column alongside columns with known metrics | | Column statistics disabled | Fixture had no metrics even when enabled | Populated fixture must return unknown column statistics when disabled | | Explicit current-snapshot selection | Separate duplicate row-total test | Fixture selects the snapshot explicitly in every matrix case | | Missing snapshot summary totals | Present | Retained | | Filter and projection/sort propagation | Present | Retained | | `COUNT(*)` skips the scan | Duplicated enabled/disabled bodies and snapshots | Both named cases retained, sharing assertions | | Explain formatting | Two identical snapshots plus weak label checks | One diagnostic snapshot; computed values verified by the matrix | ## Structure - Four ordinary named Tokio tests cover full scan / reordered projection × column statistics enabled / disabled. Two more named tests cover `COUNT(*)` scan elimination. No `test_case` macros or dependency. - Session setup uses the merged harness's `configure_session(...)`; tests never access its private context. - Native Iceberg writers create a manifest with two synthetic data-file entries and a matching manifest list. datafusion-contrib#700's `with_file` supplies the bytes to the harness. - Assertions observe query-output statistics, removing the recursive search/downcast helper and also checking projection propagation. - `insta::allow_duplicates!` is needed only for the shared, identical `COUNT(*)` inline snapshots. - The fixture is planning-only: synthetic Parquet paths are not opened. Multi-manifest merging, delete files, NDV, and verification against actual Parquet contents are not claimed here. - The genuinely historical-snapshot regression remains in datafusion-contrib#702; this PR consolidates the current-snapshot-only check from datafusion-contrib#687. ## Validation - `cargo test -p datafusion-distributed-iceberg --test statistics --locked` — all 10 cases passed - `cargo test -p datafusion-distributed-iceberg --locked` — 95 tests passed, including the doctest - `cargo test -p datafusion-distributed-iceberg --features integration --locked` — 96 tests passed, including the doctest - `cargo clippy -p datafusion-distributed-iceberg --all-targets --locked -- -D warnings` — passed, also with `--all-features` - `cargo fmt --all -- --check` - `git diff --check` - Mutation check: replacing computed column statistics with unknown values fails both enabled cases; the other eight tests pass. Mutation reverted. - Bounds mutation check: keeping the first minimum and taking the last maximum fails both enabled cases; the other eight tests pass. Mutation reverted.
…contrib#702) Rebased directly onto `iceberg-0.10` after datafusion-contrib#700, datafusion-contrib#705, datafusion-contrib#715, and datafusion-contrib#716 merged. Strengthens the existing selected-snapshot statistics test rather than adding overlapping coverage. A test-local helper uses native Iceberg builders to add snapshot 42 while leaving the original taxi snapshot current. The completed metadata and `iceberg.snapshot_id = 42` are supplied through the shared harness. The test reports `Exact(42)` rows and `Exact(4242)` bytes, distinguishing the selected snapshot from the current snapshot's 175,000 rows and 4,480,382 bytes. The summary totals are deliberately synthetic. The manifest still describes the original taxi data, so this fixture tests statistics planning rather than executing a 42-row scan. This limitation is documented beside its construction. Diff against `iceberg-0.10`: one test file, 45 added lines, no production changes. Validation: - `cargo test -p datafusion-distributed-iceberg --locked --test statistics reports_statistics_for_the_selected_snapshot` — passed - `cargo fmt --all -- --check` - `git diff --check`
…main # Conflicts: # .github/workflows/ci.yml # Cargo.lock
| insta::assert_snapshot!(plan, @r" | ||
| insta::assert_snapshot!(plan, @" | ||
| SortPreservingMergeExec: [pickup_date@0 ASC NULLS LAST] | ||
| SortExec: expr=[pickup_date@0 ASC NULLS LAST], preserve_partitioning=[true] |
There was a problem hiding this comment.
Unsure why the projection and sort order swap, I imagine it's DF upgrade related
| @@ -0,0 +1,9 @@ | |||
| # Upgrading from 4.0.0 to 5.0.0 | |||
|
|
|||
There was a problem hiding this comment.
There's an AGENTS.MD somewhere that makes my agent continuously add these and it's annoying 😆
There was a problem hiding this comment.
This is just in the case of people depending on datafusion-distributed-iceberg, but if depending on normal datafusion-distributed, it should not be a requirement. We should be good to omit this.
There was a problem hiding this comment.
Yeah, we have this in one AGENTS.MD, it's typically effective, but an overkill for the iceberg integration.
gabotechs
left a comment
There was a problem hiding this comment.
Just reviewed the commit history here, and everything looks good.
Thanks @alexanderbianchi and @sandugood for getting this integration kickstarted! it's looking pretty good.
| @@ -0,0 +1,9 @@ | |||
| # Upgrading from 4.0.0 to 5.0.0 | |||
|
|
|||
There was a problem hiding this comment.
This is just in the case of people depending on datafusion-distributed-iceberg, but if depending on normal datafusion-distributed, it should not be a requirement. We should be good to omit this.
| @@ -0,0 +1,9 @@ | |||
| # Upgrading from 4.0.0 to 5.0.0 | |||
|
|
|||
There was a problem hiding this comment.
Yeah, we have this in one AGENTS.MD, it's typically effective, but an overkill for the iceberg integration.
Summary
Merge the current
iceberg-0.10integration into DataFusion Distributedmainwhile moving its Iceberg dependencies to a pinned recentapache/iceberg-rust@mainrevision. Part of #599.This work includes:
The PR does the following
iceberg-0.10plus the dependency transition.main, which supplies DataFusion 55 and Arrow/Parquet 59.icebergandiceberg-storage-opendalto4d83bc77dc10cff851a3ef427c451ff977bc3643.For reviewers
The latest Iceberg branch has some changes to
FileScanTaskincluding a builder that we need to use. Compatibility is seen in 704d5b1 mostly iniceberg/src/proto/iceberg.proto, andiceberg/src/work_unit_wire.rs.Validation
cargo testcargo test -p datafusion-distributed-iceberg --features integrationcargo test --workspace --no-runcargo clippy --all-targets --all-features -- -D warningscargo clippy -p datafusion-distributed-iceberg --all-targets --features integration -- -D warningscargo fmt --all -- --checkgit diff --checkIceberg tests cover complete work-unit round trips including the newly carried task and deletion-vector metadata. DataFusion 55 plan snapshots and statistics traversal were updated to their current APIs.