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

   ## 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.
   -->
   
   - Closes #23099 .
   
   ## 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.  
   -->
   
   `FileScanConfig` had two overlapping ways to declare a file scan's output
   partitioning:
   
   - `partitioned_by_file_group: bool` — a shorthand meaning "the file groups 
are
     organized by Hive partition column values, so the output is 
Hash-partitioned on
     those columns", and
   - `output_partitioning: Option<Partitioning>` — a general, explicit declared
     partitioning (added in #22657).
   
   The bool is just a lazy shorthand for one specific `output_partitioning` 
value
   (`Partitioning::Hash` over the partition columns), and every place that 
consumed
   it (`output_partitioning()`, `repartitioned()`, `create_sibling_state()`) 
already
   checked `output_partitioning.is_some() || partitioned_by_file_group`. 
Keeping both
   is redundant and the `ListingTable` builder ended up setting *both*. This PR 
makes
   `output_partitioning` the single source of truth.
   
   ## 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.
   -->
   
   Following the issue's first option ("Remove `partitioned_by_file_group`"):
   
   - Remove `FileScanConfig::partitioned_by_file_group`, the corresponding
     `FileScanConfigBuilder` field, and the `with_partitioned_by_file_group` 
builder
     method.
   - `ListingTable::scan` now derives the partition-column `Partitioning::Hash`
     itself (once its file groups are finalized, so the partition count is 
correct)
     and passes it through the existing `with_output_partitioning`. The previous
     `with_output_partitioning(declared)` + 
`with_partitioned_by_file_group(...)`
     double-set is collapsed into one branch.
   - `hash_partitioning_from_partition_fields` is made `pub` so `ListingTable`
     (a separate crate) can reuse the derivation instead of duplicating the
     column-index resolution.
   - proto already round-trips `output_partitioning`, so no behavior is lost: 
the
     now-vestigial `partitioned_by_file_group` wire field is left unset on 
write and
     ignored on read. The field is kept in the `.proto` definition for backward
     compatibility.
   - `output_partitioning()` / `create_sibling_state()` / `repartitioned()` now 
key
     solely off `output_partitioning`.
   
   ## 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 — by existing tests, updated to the new single-field model:
   
   - `datafusion-datasource`: `test_output_partitioning_with_partition_columns`,
     `test_output_partitioning_no_partition_columns`,
     `test_declared_output_partitioning_projects_with_scan`, and the 
`file_stream`
     work-stealing test `morsel_partitioned_by_file_group_keeps_files_local` 
(which
     verifies that a declared output partitioning keeps each stream's files 
local).
   - `datafusion-proto`: `roundtrip_parquet_exec_output_partitioning` (and the 
other
     `roundtrip_parquet_exec_*` cases) cover the partitioning round-trip. The 
old
     `roundtrip_parquet_exec_partitioned_by_file_group` test exercised the 
removed
     API and is dropped, as its coverage is subsumed by the 
`output_partitioning`
     round-trip test.
   
   All of the above pass, along with `cargo fmt --all --check` and
   `cargo clippy --all-targets --all-features -- -D warnings` for the affected
   crates.
   
   ## 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.
   -->
   
   Yes — public API changes :
   
   - Removed: the public `FileScanConfig::partitioned_by_file_group` field and 
the
     `FileScanConfigBuilder::with_partitioned_by_file_group` method. Callers 
should
     set `with_output_partitioning(Some(Partitioning::Hash(..)))` instead (or 
use the
     now-public `hash_partitioning_from_partition_fields` helper).
   - Added: `hash_partitioning_from_partition_fields` is now `pub`.
   
   There is no change to query results, physical plans, or the serialized
   (proto) wire format. `cargo-semver-checks` will flag the removals as 
breaking,
   which is expected for this cleanup.
   


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