mbutrovich opened a new pull request, #22600:
URL: https://github.com/apache/datafusion/pull/22600

   ## Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and 
enhancements and this helps us generate change logs for our releases. You can 
link an issue to this PR using the GitHub syntax. For example `Closes #123` 
indicates that this PR will close issue #123.
   -->
   
   Followup to #22026 — addresses two review comments from @adriangb that 
landed after the PR was already in the merge queue.
   
   ## Rationale for this change
   
   <!--
    Why are you proposing this change? If this is already explained clearly in 
the issue then this section is not needed.
    Explaining clearly why changes are proposed helps reviewers understand your 
changes and offer better suggestions for fixes.  
   -->
   
   Two pieces of feedback on the `TableSchema` API introduced in #22026:
   
   1. https://github.com/apache/datafusion/pull/22026#discussion_r3319225261 — 
`TableSchema::with_virtual_columns` shouldn't exist as a non-deprecated 
counterpart to the already-deprecated `TableSchema::with_table_partition_cols`. 
Callers should use `TableSchemaBuilder` directly. Every existing call site 
already does, so the method has no users.
   2. https://github.com/apache/datafusion/pull/22026#discussion_r3319230237 — 
`schema_without_virtual_columns` was rebuilding the schema on every call. It 
can be computed once at construction and returned by reference, matching the 
convention used by every other accessor on `TableSchema` (`file_schema`, 
`table_schema`, `table_partition_cols`, `virtual_columns` all return `&`).
   
   ## What changes are included in this PR?
   
   <!--
   There is no need to duplicate the description in the issue here but it is 
sometimes worth providing a summary of the individual changes in this PR.
   -->
   
   - Remove `TableSchema::with_virtual_columns`. Callers must use 
`TableSchemaBuilder::with_virtual_columns` (no in-tree callers needed updating).
   - Cache `schema_without_virtual_columns` on `TableSchema`, computed once in 
`TableSchemaBuilder::build`. When there are no virtual columns the cached field 
shares the same `Arc` as `table_schema`.
   - Accessor `schema_without_virtual_columns(&self)` now returns `&SchemaRef` 
instead of an owned `SchemaRef`, matching the rest of the struct's accessors. 
Updated the one in-tree caller in `datasource-parquet/src/source.rs`.
   
   ## Are these changes tested?
   
   <!--
   We typically require tests for all PRs in order to:
   1. Prevent the code from being accidentally broken by subsequent changes
   2. Serve as another way to document the expected behavior of the code
   
   If tests are not included in your PR, please explain why (for example, are 
they covered by existing tests)?
   -->
   
   Yes — covered by the existing `table_schema` unit tests and the 
`datasource-parquet` test suite, all of which still pass. The change is a 
refactor with no behavioral difference: the cached schema produced in `build()` 
is byte-for-byte identical to what the previous accessor allocated on each call.
   
   ## Are there any user-facing changes?
   
   <!--
   If there are user-facing changes then we may require documentation to be 
updated before approving the PR.
   -->
   
   <!--
   If there are any breaking changes to public APIs, please add the `api 
change` label.
   -->
   
   Two API changes against the `TableSchema` surface added in #22026 (which has 
not been released):
   
   - `TableSchema::with_virtual_columns` removed. Use 
`TableSchemaBuilder::with_virtual_columns` instead.
   - `TableSchema::schema_without_virtual_columns` return type changed from 
`SchemaRef` to `&SchemaRef`. Callers that need an owned value should 
`Arc::clone` the result.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to