Skip to content

Add ObjectStore-backed TempFileFactor / spill example - #23170

Merged
alamb merged 7 commits into
apache:mainfrom
alamb:codex/object-store-spill-example
Jul 26, 2026
Merged

Add ObjectStore-backed TempFileFactor / spill example#23170
alamb merged 7 commits into
apache:mainfrom
alamb:codex/object-store-spill-example

Conversation

@alamb

@alambalamb commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

PR #21882 adds custom spill file support.

Having an example showing how a downstream application can use this new API will help make sure the API is good enough for our needs

What changes are included in this PR?

This PR adds a small example showing how users can back spill files with an ObjectStore, using a local object store for a runnable example while keeping the implementation applicable to remote stores.

Are these changes tested?

Yes by CI

Are there any user-facing changes?

Yes. This adds a new example for configuring ObjectStore-backed spill files.

@github-actionsgithub-actionsBot added documentation Improvements or additions to documentation execution Related to the execution crate physical-plan Changes to the physical-plan crate auto detected api change Auto detected API change labels Jun 24, 2026
@alamb
alambforce-pushed the codex/object-store-spill-example branch from 4dfdfcb to e97ed5dCompareJune 24, 2026 22:16
@alambalamb changed the title Add ObjectStore-backed spill exampleAdd ObjectStore-backed TempFileFactor / spill exampleJun 24, 2026

@alambalamb left a comment

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

// specific language governing permissions and limitations
// under the License.

//! See `main.rs` for how to run it.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

This is the whole point of this PR: an example of implementing remote spilling

@alamb
alambforce-pushed the codex/object-store-spill-example branch from b5fe466 to 180d421CompareJune 29, 2026 19:36
@github-actionsgithub-actionsBot removed documentation Improvements or additions to documentation physical-plan Changes to the physical-plan crate auto detected api change Auto detected API change labels Jun 29, 2026
@alamb
alambforce-pushed the codex/object-store-spill-example branch from 180d421 to 584169fCompareJune 29, 2026 20:58
@alambalamb added the documentation Improvements or additions to documentation label Jun 29, 2026
self
}

/// Configure a custom factory for creating temporary spill files.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

This is a small API to make configuring spill files easier

@alamb
alamb marked this pull request as ready for review June 29, 2026 20:59
Comment on lines +187 to +189
Ok(Box::pin(stream::once(async move {
Ok(store.get(&location).await?.bytes().await?)
})))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit. bytes().await collects the entrie spill opbject into a single Bytes before DataFusion can consume it. Since SpillFile::read_stream already returns a byte stream, I think we can preserve chunked reads by deferring the async get() and flattening the object-store stream, roughly:

let stream = stream::once(asyncmove{
store.get(&location).await.map(|result| result.into_stream())}).try_flatten().map_err(Into::into);Ok(Box::pin(stream))

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

great idea -- done in fd3ce43

@github-actionsgithub-actionsBot removed the documentation Improvements or additions to documentation label Jun 30, 2026
@alambalamb added the documentation Improvements or additions to documentation label Jun 30, 2026
@github-actionsgithub-actionsBot removed the documentation Improvements or additions to documentation label Jun 30, 2026
@pantShrey

Copy link
Copy Markdown
Contributor

Looks good to me @alamb, thank you for this clean example!

@Phoenix500526Phoenix500526 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good to me too. 😊

@alambalamb added the documentation Improvements or additions to documentation label Jul 22, 2026
@github-actionsgithub-actionsBot removed the documentation Improvements or additions to documentation label Jul 22, 2026
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.71%. Comparing base (96e8fdf) to head (7c31aa7).
⚠️ Report is 1 commits behind head on main.

Files with missing linesPatch %Lines
datafusion/execution/src/disk_manager.rs0.00%10 Missing ⚠️
Additional details and impacted files
@@ Coverage Diff @@## main #23170 +/- ##
==========================================
- Coverage 80.71% 80.71% -0.01% 
==========================================
Files 1089 1089 Lines 368911 368921 +10 Branches 368911 368921 +10 ==========================================
- Hits 297778 297768 -10 - Misses 53378 53394 +16 - Partials 17755 17759 +4 

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@AdamGSAdamGS left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@alamb
alamb added this pull request to the merge queueJul 26, 2026
@alamb

Copy link
Copy Markdown
ContributorAuthor

Thank you for the review @AdamGS

Merged via the queue into apache:main with commit 551c592Jul 26, 2026
38 checks passed
@alamb
alamb deleted the codex/object-store-spill-example branch July 26, 2026 17:59
kosiew pushed a commit to kosiew/datafusion that referenced this pull request Aug 12, 2026
## Which issue does this PR close?
- Related to
apache#21882 (comment).
## Rationale for this change
PR apache#21882 adds custom spill file support. Having an example showing how a downstream application can use this new
API will help make sure the API is good enough for our needs
## What changes are included in this PR?
This PR adds a small example showing how users can back spill files with
an `ObjectStore`, using a local object store for a runnable example
while keeping the implementation applicable to remote stores.
## Are these changes tested?
Yes by CI
## Are there any user-facing changes?
Yes. This adds a new example for configuring ObjectStore-backed spill
files.
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

executionRelated to the execution crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@alamb@pantShrey@codecov-commenter@AdamGS@Phoenix500526