-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Schema adapter helper #16108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Schema adapter helper #16108
Conversation
| let (field_mappings, projection) = create_field_mapping( | ||
| file_schema, | ||
| &self.projected_table_schema, | ||
| can_cast_field, | ||
| )?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refactor into a helper function so that we can re-use in later PRs for deep-nested SchemaAdapter
adriangb
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks very nice to me. The additional tests -despite this being existing code- is a great contribution.
|
@adriangb |
b128412 to
b598814
Compare
b598814 to
9d93dac
Compare
alamb
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
You're welcome @alamb |
Which issue does this PR close?
This is part of a series of PRs re-implementing #15295 to close #14657 by adding schema‐evolution support for listing‐based tables with nested structs in DataFusion.
Rationale for this change
This refactor improves the flexibility and robustness of schema adaptation in DataFusion by extracting casting logic into a reusable helper. It enhances clarity, testability, and reusability of core logic for mapping file schemas to table schemas—especially important for supporting schema evolution with nested fields.
What changes are included in this PR?
can_cast_fieldto encapsulate field-level type casting logic with clear error messaging.create_field_mapping, a helper for generating field mappings and projections between file and table schemas.DefaultSchemaAdapter::map_schemato usecreate_field_mapping, reducing duplication and improving readability.SchemaMapping::newconstructor for cleaner instantiation.create_field_mappingunder various mapping strategies.Are these changes tested?
✅ Yes, comprehensive tests are included for:
can_cast_field)create_field_mapping)map_schemaandSchemaMapping::map_batchThese tests cover both happy-path and failure scenarios.
Are there any user-facing changes?
No user-facing changes. This is an internal refactor that improves schema handling logic and prepares the codebase for supporting complex schema evolution use cases in a modular way.