Skip to content

Add ObjectStore-backed TempFileFactor / spill example#23170

Open
alamb wants to merge 6 commits into
apache:mainfrom
alamb:codex/object-store-spill-example
Open

Add ObjectStore-backed TempFileFactor / spill example#23170
alamb wants to merge 6 commits into
apache:mainfrom
alamb:codex/object-store-spill-example

Conversation

@alamb

@alamb alamb 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-actions github-actions Bot 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
alamb force-pushed the codex/object-store-spill-example branch from 4dfdfcb to e97ed5d Compare June 24, 2026 22:16
@alamb alamb changed the title Add ObjectStore-backed spill example Add ObjectStore-backed TempFileFactor / spill example Jun 24, 2026

@alamb alamb left a comment

Copy link
Copy Markdown
Contributor Author

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
Contributor Author

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
alamb force-pushed the codex/object-store-spill-example branch from b5fe466 to 180d421 Compare June 29, 2026 19:36
@github-actions github-actions Bot 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
alamb force-pushed the codex/object-store-spill-example branch from 180d421 to 584169f Compare June 29, 2026 20:58
@alamb alamb 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
Contributor Author

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(async move {
    store.get(&location).await.map(|result| result.into_stream())
})
.try_flatten()
.map_err(Into::into);
Ok(Box::pin(stream))

Copy link
Copy Markdown
Contributor Author

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-actions github-actions Bot removed the documentation Improvements or additions to documentation label Jun 30, 2026
@alamb alamb added the documentation Improvements or additions to documentation label Jun 30, 2026
@github-actions github-actions Bot 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!

@Phoenix500526 Phoenix500526 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. 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

execution Related to the execution crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants