Add From<&SchemaRef> impls to avoid explicit schema clones#61
Merged
adriangb merged 1 commit intoMay 26, 2026
Merged
Conversation
Add `From<&SchemaRef>` for `TableSchema`, and `From<SchemaRef>` / `From<&SchemaRef>` for `TableSchemaBuilder`, so callers can construct a schema/builder from a borrowed `SchemaRef` without writing an explicit `Arc::clone(..)` / `.clone()` at every call site. Port the existing call sites that explicitly cloned the file schema to the new `From` impls: - `TableSchema::builder(Arc::clone(&x))` -> `TableSchemaBuilder::from(&x)` - `TableSchema::from(Arc::clone(&x))` -> `TableSchema::from(&x)` The `Arc::clone` still happens inside the `From` impl; this just removes the boilerplate at the call sites. Owned-value call sites are unchanged. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
alamb
commented
May 26, 2026
| /// Creates a file source for this table | ||
| fn create_file_source(&self) -> Arc<dyn FileSource> { | ||
| let table_schema = TableSchema::builder(Arc::clone(&self.file_schema)) | ||
| let table_schema = TableSchemaBuilder::from(&self.file_schema) |
Author
There was a problem hiding this comment.
the point of this PR is to simplity the code and avoid a bunch of explicit clones
Author
|
FYI @adriangb |
Member
|
thanks Andrew! |
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.
Proposed addition to
This builds on the new
TableSchemaBuilderby addingFromimpls that take a borrowedSchemaRef, so call sites no longer need an explicitArc::clone(..)/.clone():