Skip to content

fix(datafusion): decode IcebergTableScan batches at the session batch_size - #58

Merged
bjchambers merged 2 commits into
spiceai-0.11.0-df-55from
ben/scan-session-batch-size
Oct 12, 2026
Merged

bjchambers merged 2 commits into
spiceai-0.11.0-df-55from
ben/scan-session-batch-size

Conversation

@bjchambers

Copy link
Copy Markdown

What

IcebergTableScan::execute ignored its TaskContext, so every scan decoded batches at the Parquet reader's 1024-row default rather than the session's batch_size (8192 by default). This passes context.session_config().batch_size() through build_record_batch_stream and build_table_scan to TableScanBuilder::with_batch_size.

This is the same layer DataFusion's own file scans read it from: FileScanConfig takes the batch size from the task's session config when the plan doesn't set one. Reading it at execute also means the distributed codec needs no change, because each executor supplies its own TaskContext.

Why

Every operator downstream of the scan pays its per-batch cost per batch, so 1024-row batches cost 8x the batches. On a first load of a 40.2M-row Iceberg table into a Spice acceleration, this change alone took the load from 19.1–19.5 s to 15.4–16.2 s (interleaved A/B, 3 repetitions each). Refs spiceai/spiceai#15064.

Tests

The guard for this patch lives in spiceai/spiceai, per its fork-patch ledger, so it survives a branch re-cut. It asserts a provider scan emits batches of the session batch_size, and fails at 1024 rows on the current pin. It lands in the same pull request that moves the pin.

The DataFusion integration has since moved upstream to apache/datafusion-iceberg, which has the same _context gap; this is worth upstreaming there separately.

…_size

IcebergTableScan::execute ignored its TaskContext, so the scan decoded with the
Parquet reader's 1024-row default rather than the session's batch_size (8192 by
default). Every downstream operator then paid its per-batch cost 8x as often.
Copilot AI balanced review requested due to automatic review settings October 12, 2026 19:46
Copilot AI previously approved these changes Oct 12, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approved

The focused configuration propagation is complete and consistent across both scan modes.

0 open findings

What changed in this PR

Aligns Iceberg scan decoding with DataFusion’s session batch size, reducing downstream per-batch overhead.

Changes:

  • Reads batch_size from the execution TaskContext.
  • Propagates it to TableScanBuilder.
File Description
crates/​integrations/​datafusion/​src/​physical_plan/​scan.rs Applies the session batch size when building scan streams.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Copilot AI balanced review requested due to automatic review settings October 12, 2026 20:12
Copilot AI dismissed their stale review, a newer Copilot review was requested October 12, 2026 20:13

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approved

The batch-size propagation is correct for both lazy and pre-planned scan paths, with no unresolved issues found.

0 open findings

🧠 Review effort: Balanced

@bjchambers
bjchambers merged commit 1707b34 into spiceai-0.11.0-df-55 Oct 12, 2026
21 checks passed
@bjchambers
bjchambers deleted the ben/scan-session-batch-size branch October 12, 2026 20:35
bjchambers added a commit to spiceai/spiceai that referenced this pull request Oct 12, 2026
Move all six iceberg-rust pins to 1707b349, the merge of
spiceai/iceberg-rust#58 into spiceai-0.11.0-df-55, and drop the TEMPORARY
marker from the fork-ledger row. Cargo.lock changes only the iceberg-rust
package sources.

Pass RecordBatch::num_rows directly in the batch-size guard, which the
pedantic clippy pass over tests requires.

Refs #15064
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.

3 participants