Decouple the FileSource trait from the concrete FileScanConfig DataSource#23467
Draft
mitchsw wants to merge 1 commit into
Draft
Decouple the FileSource trait from the concrete FileScanConfig DataSource#23467mitchsw wants to merge 1 commit into
FileSource trait from the concrete FileScanConfig DataSource#23467mitchsw wants to merge 1 commit into
Conversation
…l, via FileSourceArgs FileSource::create_file_opener and create_morselizer took a &FileScanConfig, tying the file-format engines to that one concrete DataSource. A custom DataSource could not reuse an existing FileSource (e.g. ParquetSource) without first constructing a FileScanConfig. Introduce FileSourceArgs, a small freely-constructible struct carrying the open-time inputs a FileSource needs (object_store, batch_size, limit, preserve_order, file_compression_type, expr_adapter_factory), and have both methods take &FileSourceArgs instead of &FileScanConfig. FileScanConfig builds it inline in open_with_args; a custom DataSource can build it the same way. Also remove FileSource::with_batch_size: batch size now flows through FileSourceArgs, so sources no longer store it or guard it with an expect(). This opens the door for custom DataSource implementations to reuse FileSource without depending on FileScanConfig. Updates the Parquet/Csv/Json/Arrow/Avro sources, the test sources, the csv/json opener example, and adds a 55.0.0 upgrade note.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
FileSourcetrait from the concreteFileScanConfigDataSource#23463Rationale for this change
FileSource(the per-format scan trait) is currently coupled to its concreteFileScanConfigparent. AFileSource's open-time methods take a&FileScanConfigand use it as a "bag of args". That forces a customDataSourceto build aFileScanConfigit doesn't need just to reuse an existingFileSource. Passing those inputs explicitly in an arg struct decouples the two.This PR strictly layers the types:
What changes are included in this PR?
FileSourceArgs, whichFileSource::create_file_opener/create_morselizernow take instead ofFileScanConfig base_configobject_storeandFileSource::with_batch_sizeintoFileSourceArgs.FileScanConfigbuildsFileSourceArgsinline in its open path (no-op).FileSourceimplementations and thecsv_json_openerexample.Why also remove
with_batch_size?Not strictly needed to close #23463 (the decoupling only needs the
create_*signature change), but bundled as a cleanup:batch_sizeis an open-time input like the others — it belongs inFileSourceArgs, not in a separate mutate-and-clone method.Option<usize>and later.expect("Batch size must be set …"); a required arg is compiler-enforced.main, andArrowSourceignores its argument (fn with_batch_size(&self, _batch_size: usize)).Happy to drop this cleanup if reviewers prefer a narrower PR.
Are these changes tested?
Behavior is unchanged for the built-in
FileScanConfigpath, so existing scan tests cover it.cargo check/clippy/fmtand the core tests pass locally.Are there any user-facing changes?
Yes, a breaking change to the public
FileSourcetrait. CustomFileSourceimplementors must update. A simple migration guide is incliuded.