Repository navigation
[Data] DSv2 Reorg [5/6]: Move partition pruning onto FileScanner and let it reach scanners without filter pushdown - #66478
Merged
goutamvenkat-anyscale merged 2 commits intoSep 25, 2026
Conversation
…let it reach scanners without filter pushdown Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: Aarrya <[email protected]>
AarryaSaraf
marked this pull request as ready for review
September 24, 2026 23:21
Contributor
There was a problem hiding this comment.
Code Review
This pull request refactors partition pruning by moving its implementation from ArrowFileScanner to the base FileScanner class, enabling all file-based datasources (including non-Arrow formats) to prune files based on path-derived partition values. The logical operator planning and predicate pushdown logic have been updated to accommodate scanners that support partition pruning but not full filter pushdown. New unit tests have been added to verify this functionality. There are no review comments to address, so I have no additional feedback to provide.
goutamvenkat-anyscale
pushed a commit
that referenced
this pull request
Sep 25, 2026
…get_size_estimator (#66450) ## Description `DataSourceV2` had two hooks for grouping listing rows into read units: `get_size_estimator()`, which defaulted to `None`, and `get_file_partitioner(**kwargs)`, which defaulted to a `RoundRobinPartitioner` fed by that estimator. Only `read_api` called either, and Parquet, the one implementation, overrode both but its partitioner never used the estimator, so the second hook did nothing. A new format author had to guess which of the two to override and what a `None` estimator meant. This PR keeps one hook. `get_file_partitioner` is abstract, and each datasource returns the partitioner it wants, built from whatever estimator or metadata it chooses, the way Parquet already does. ### What changes 1. **`datasource_v2.py`.** `get_file_partitioner(self, *, hints=None)` is abstract; `get_size_estimator` is removed. The docstring says what a partitioner must be (pickled into every listing task, so cheap to pickle) and when to return `None`. 2. **`partitioners/file_partitioner.py`.** New frozen dataclass `PartitionHints(min_bucket_size, max_bucket_size, num_buckets)`: the three values `read_api` computes from `DataContext` and `override_num_blocks`. A partitioner may ignore them. 3. **`partitioners/round_robin_partitioner.py`.** `RoundRobinPartitioner(estimator, *, hints)` takes the dataclass instead of the same three ints, so a datasource forwards `hints` untouched. 4. **`read_api.py`.** Builds `PartitionHints` and passes it by keyword. No more estimator lookup. 5. **`parquet_datasource_v2.py`.** `get_size_estimator` and its import are gone. `get_file_partitioner(self, **kwargs)` is unchanged; it still sizes bins from `RAY_DATA_PARQUET_BIN_PACKING_BYTES`. 6. **Tests.** `test_parquet_datasource_v2.py`: the estimator test becomes "returns an `OnlineBinPacker` whatever the hints". `test_datasource_v2.py`: the minimal-members stub implements the new abstract method. `test_file_partitioners.py`: the two round-robin tests build a `PartitionHints`. `hints` is keyword-only so an override that ignores it can keep `**kwargs`, as Parquet does. Each listing task holds its own pickled copy of the partitioner, so an estimator that samples a file (`SamplingInMemorySizeEstimator`) reads once per listing task. `ParquetInMemorySizeEstimator` stays in the tree; it now has no production caller and is the subject of a separate change. ## Additional information Not a duplicate: no open PR touches these hooks. This PR sits directly on `master`; `[5/6]` #66478 is independent of it. Checks run locally from this branch (macOS, `~/ray/.venv`): ``` pytest -q tests/unit/datasource_v2 # 140 passed ``` `ruff`, `black` and `pydoclint` at the pre-commit pins are clean; `pyrefly` via `ci/lint/pyrefly-check.sh` reports 59 errors, identical to `master`, none new. Written with Claude Code; I reviewed every changed line and ran the tests above. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Signed-off-by: Aarrya <[email protected]> Co-authored-by: Claude Fable 5.1 <[email protected]>
Comment on lines
426
to
+446
| residual_unpushed = split.residual_predicate | ||
| if split.partition_predicate is not None: | ||
| new_scanner = new_scanner.prune_partitions(split.partition_predicate) | ||
| if split.data_predicate is not None: | ||
| if split.data_predicate is not None and pushes_filters: | ||
| # ``push_filters`` may decline part of what it was offered; that | ||
| # leftover is a conjunct of the same chain, so ``&`` rebuilds it. | ||
| new_scanner, residual_declined = new_scanner.push_filters( | ||
| split.data_predicate | ||
| ) | ||
| residual_unpushed = combine_predicates(residual_unpushed, residual_declined) | ||
| elif split.data_predicate is not None: | ||
| # No filter pushdown: the data-column conjuncts stay in a | ||
| # ``Filter`` above the read, and only the partition ones move. | ||
| residual_unpushed = combine_predicates( | ||
| residual_unpushed, split.data_predicate | ||
| ) | ||
|
|
||
| if new_scanner is self.scanner: | ||
| # Nothing was pushed (e.g. a data-only predicate on a scanner that | ||
| # only prunes partitions); keep the original ``Filter``. | ||
| return self |
Contributor
There was a problem hiding this comment.
A cleaner version:
residual_unpushed = split.residual_predicate
if split.partition_predicate is not None:
new_scanner = new_scanner.prune_partitions(split.partition_predicate)
if split.data_predicate is not None:
if pushes_filters:
# ``push_filters`` may decline part of what it was offered; that
# leftover is another conjunct of the same chain, so it goes back
# into the residual.
new_scanner, declined = new_scanner.push_filters(split.data_predicate)
else:
# No filter pushdown: the data-column conjuncts stay in a ``Filter``
# above the read, and only the partition ones move.
declined = split.data_predicate
residual_unpushed = combine_predicates(residual_unpushed, declined)
if new_scanner is self.scanner:
# Nothing was pushed (e.g. a data-only predicate on a scanner that
# only prunes partitions); keep the original ``Filter``.
return self
…dicate under one guard Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: Aarrya <[email protected]>
goutamvenkat-anyscale
approved these changes
Sep 25, 2026
goutamvenkat-anyscale
enabled auto-merge (squash)
September 25, 2026 18:50
goutamvenkat-anyscale
pushed a commit
that referenced
this pull request
Sep 29, 2026
…mmon/ and formats/parquet/ (#66497) ## Description `python/ray/data/_internal/datasource_v2/` grouped files by role (`listing/`, `scanners/`, `readers/`, `partitioners/`, `chunkers/`), and each role folder mixed the abstract class, the format-independent implementation and the Parquet one. `listing/file_indexer.py` held `FileIndexer` next to `NonSamplingFileIndexer`, with `FooterFileIndexer` two files over. Someone adding a format could not tell from the tree what they must implement, what they may reuse, and what is Parquet's business. This PR regroups the package by kind: `interfaces/` is what a format implements, `common/` is what it may reuse, `formats/<name>/` is one folder per format. `interfaces/` imports nothing else in the package, `common/` imports only `interfaces/`, `formats/` may import both. No class, signature or behaviour changes; every import path changes. ### The layout ``` python/ray/data/_internal/datasource_v2/ __init__.py InputSplit TypeVar (unchanged) README.md new: layout rule, how a read flows, what a format implements interfaces/ abstract classes and the types their signatures use datasource_v2.py DataSourceV2, DatasourceCategory, FileDataSourceV2, DataSourceWithMetadata scanner.py Scanner reader.py Reader file_indexer.py FileIndexer, FileInfo file_pruner.py FilePruner file_partitioner.py FilePartitioner, PartitionHints in_memory_size_estimator.py InMemorySizeEstimator supports_metadata.py SupportsMetadata, MetadataType pushdown.py SupportsFilterPushdown, SupportsColumnPushdown, SupportsLimitPushdown, SupportsPartitionPruning, ListFilesPushdown read_units.py ReadUnit, ReadUnitFragment synthesized_columns.py SynthesizedColumn, ReadUnitPosition file_manifest.py FileManifest, ChunkMetadata, create_chunk_metadata common/ format-independent implementations non_sampling_file_indexer.py NonSamplingFileIndexer listing_utils.py, indexing_utils.py file_pruners.py FileExtensionPruner, PartitionPruner, PartitionPredicatePruner round_robin_partitioner.py RoundRobinPartitioner online_bin_packer.py OnlineBinPacker, BinItem, Bin size_estimators.py SamplingInMemorySizeEstimator file_scanner.py FileScanner arrow_file_scanner.py ArrowFileScanner file_reader.py FileReader synthesized_columns.py PathColumn, RowHashColumn pushdown_utils.py derive_list_files_pushdown, combine_predicates formats/ parquet/ parquet_datasource_v2.py ParquetDatasourceV2 parquet_scanner.py ParquetScanner parquet_file_reader.py ParquetFileReader footer_file_indexer.py FooterFileIndexer footer_reader.py FooterReader actor parquet_footer_types.py RowGroupInfo, FileChunks, ParquetRowGroupChunkMetadata parquet_size_estimator.py ParquetInMemorySizeEstimator parquet_file_chunking_utils.py, parquet_row_group_coalescing.py, parquet_utils.py ``` ### What changes 1. **32 renames** into the three folders; `git diff -M` pairs them, most at 90%+ similarity with the rest being import lines. 2. **7 files split** where an interface sat next to its implementations: `listing/file_indexer.py`, `listing/file_pruners.py`, `readers/in_memory_size_estimator.py`, `readers/synthesized_columns.py`, `logical_optimizers.py` (mixins to `interfaces/pushdown.py`, helpers to `common/pushdown_utils.py`), `chunkers/file_chunker.py` (dissolved into `interfaces/file_manifest.py` and `formats/parquet/parquet_footer_types.py`) and `chunkers/parquet_footer_types.py` (`BinItem`/`Bin` to `common/online_bin_packer.py`). 3. **27 files outside the package** change import lines only: `read_api.py`, the legacy `ParquetDatasource`, logical rules, planners, tests. Tests keep their locations. 4. **Nine type errors fixed** in `common/indexing_utils.py`, `common/non_sampling_file_indexer.py` and `interfaces/file_manifest.py`. These three files were in `ci/lint/pyrefly-excluded-files.txt` under their old paths, so the move puts them under pyrefly for the first time. The fixes: re-raise after `_handle_read_os_error` returns instead of reading an unbound `file_info`; the threaded lister always wraps results in `OrderedFileResult` and unwraps on yield, so `input_path_index` is an `int` and there is no `FileInfo | OrderedFileResult` union; `FileManifest.__init__` asserts a `TableBlockAccessor` before calling `column_names()`. `ci/` is not touched. 5. **`README.md`** (new) for the package. One import still crosses the layering line: `common/online_bin_packer.py` reads and writes `ParquetRowGroupChunkMetadata` from `formats/parquet/`. The packer is meant for any format with sized sub-file units, so it stays in `common/`. A follow-up PR, once #66121 has settled the packer's fields, adds a generic chunk-run type in `interfaces/` that the packer works on and makes the Parquet type a subclass of it. Doing that here would turn a reviewable set of renames into content changes. ## Additional information Follows #66450 (`[4/6]`) and #66478 (`[5/6]`), both merged; the branch sits directly on `master`. Not a duplicate: #62573 (WIP, `_internal/` wide) does not touch `datasource_v2/`. Checks run locally from this branch (macOS, `~/ray/.venv`): ``` pytest -q tests/unit/datasource_v2 # 146 passed ``` `ruff`, `black` and `pydoclint` at the pre-commit pins are clean on every changed Python file; `tests/test_import.py` (from #66463) passes; `pyrefly` via `ci/lint/pyrefly-check.sh` reports 59 errors, identical to `master`, none new. Written with Claude Code; I reviewed every changed line and ran the tests above. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Signed-off-by: Aarrya <[email protected]> Co-authored-by: Claude Fable 5.1 <[email protected]>
nadongjun
pushed a commit
to nadongjun/ray
that referenced
this pull request
Oct 6, 2026
…get_size_estimator (ray-project#66450) ## Description `DataSourceV2` had two hooks for grouping listing rows into read units: `get_size_estimator()`, which defaulted to `None`, and `get_file_partitioner(**kwargs)`, which defaulted to a `RoundRobinPartitioner` fed by that estimator. Only `read_api` called either, and Parquet, the one implementation, overrode both but its partitioner never used the estimator, so the second hook did nothing. A new format author had to guess which of the two to override and what a `None` estimator meant. This PR keeps one hook. `get_file_partitioner` is abstract, and each datasource returns the partitioner it wants, built from whatever estimator or metadata it chooses, the way Parquet already does. ### What changes 1. **`datasource_v2.py`.** `get_file_partitioner(self, *, hints=None)` is abstract; `get_size_estimator` is removed. The docstring says what a partitioner must be (pickled into every listing task, so cheap to pickle) and when to return `None`. 2. **`partitioners/file_partitioner.py`.** New frozen dataclass `PartitionHints(min_bucket_size, max_bucket_size, num_buckets)`: the three values `read_api` computes from `DataContext` and `override_num_blocks`. A partitioner may ignore them. 3. **`partitioners/round_robin_partitioner.py`.** `RoundRobinPartitioner(estimator, *, hints)` takes the dataclass instead of the same three ints, so a datasource forwards `hints` untouched. 4. **`read_api.py`.** Builds `PartitionHints` and passes it by keyword. No more estimator lookup. 5. **`parquet_datasource_v2.py`.** `get_size_estimator` and its import are gone. `get_file_partitioner(self, **kwargs)` is unchanged; it still sizes bins from `RAY_DATA_PARQUET_BIN_PACKING_BYTES`. 6. **Tests.** `test_parquet_datasource_v2.py`: the estimator test becomes "returns an `OnlineBinPacker` whatever the hints". `test_datasource_v2.py`: the minimal-members stub implements the new abstract method. `test_file_partitioners.py`: the two round-robin tests build a `PartitionHints`. `hints` is keyword-only so an override that ignores it can keep `**kwargs`, as Parquet does. Each listing task holds its own pickled copy of the partitioner, so an estimator that samples a file (`SamplingInMemorySizeEstimator`) reads once per listing task. `ParquetInMemorySizeEstimator` stays in the tree; it now has no production caller and is the subject of a separate change. ## Additional information Not a duplicate: no open PR touches these hooks. This PR sits directly on `master`; `[5/6]` ray-project#66478 is independent of it. Checks run locally from this branch (macOS, `~/ray/.venv`): ``` pytest -q tests/unit/datasource_v2 # 140 passed ``` `ruff`, `black` and `pydoclint` at the pre-commit pins are clean; `pyrefly` via `ci/lint/pyrefly-check.sh` reports 59 errors, identical to `master`, none new. Written with Claude Code; I reviewed every changed line and ran the tests above. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Signed-off-by: Aarrya <[email protected]> Co-authored-by: Claude Fable 5.1 <[email protected]>
nadongjun
pushed a commit
to nadongjun/ray
that referenced
this pull request
Oct 6, 2026
…let it reach scanners without filter pushdown (ray-project#66478) ## Description Partition pruning drops whole files by the partition values in their paths. It lived on `ArrowFileScanner`, so only PyArrow Dataset formats had it, and `ReadFiles.apply_predicate` required filter pushdown, so a scanner without it never received a predicate at all. Partition values come from paths and the `Partitioning` spec, not from file contents, so the pruning is the same for every file format. This PR moves it to `FileScanner` and lets partition conjuncts reach a scanner that has nothing else to push. ### What changes 1. **`scanners/file_scanner.py`.** `FileScanner` becomes a `SupportsPartitionPruning`. The `partitioning` and `partition_predicate` fields and the five pruning members move here from `ArrowFileScanner` unchanged. 2. **`scanners/arrow_file_scanner.py`.** Loses them; keeps filter, column and limit pushdown. 3. **`logical/operators/read_operator.py`.** `supports_predicate_pushdown` accepts either mixin. In `apply_predicate`, data conjuncts go to `push_filters` only when the scanner has it and otherwise stay in the `Filter`; when nothing was pushed it returns `self` so the original `Filter` is kept. 4. **Comments** in `scanner.py`, `plan_read_files_op.py`, `file_pruners.py` and `logical_optimizers.py` now name `FileScanner`. 5. **`tests/unit/datasource_v2/test_file_scanner.py`** (new): a scanner with no pushdown of its own takes a partition predicate, data conjuncts stay in a `Filter` above the read, nothing-to-push keeps the original operator, listing derives the same pruner as the reader, and `prune_input_split` drops files by path. ```mermaid flowchart TD P["ReadFiles.apply_predicate(expr)"] --> S["split expr by partition columns"] S -->|partition conjuncts| PP["scanner.prune_partitions"] S -->|data conjuncts, scanner pushes filters| PF["scanner.push_filters"] S -->|data conjuncts, no filter pushdown| F["stay in Filter above the read"] PP --> N{"anything pushed?"} PF --> N N -->|no| K["return self: original Filter kept"] N -->|yes| R["new ReadFiles, residual Filter if any"] ``` `ParquetScanner` and every other `ArrowFileScanner` behave as before: same members, inherited one level up. ## Additional information Not a duplicate: no open PR touches partition pruning or the `ReadFiles` pushdown gate. ray-project#65989 (mine) is about synthesized-column conjuncts and is independent. `[4/6]` ray-project#66450 is parked; this PR sits directly on `master`. Checks run locally from this branch (macOS, `~/ray/.venv`): ``` pytest -q tests/unit/datasource_v2 # 146 passed ``` `ruff`, `black` and `pydoclint` at the pre-commit pins are clean; `pyrefly` via `ci/lint/pyrefly-check.sh` reports 59 errors, identical to `master`, none new. Written with Claude Code; I reviewed every changed line and ran the tests above. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Signed-off-by: Aarrya <[email protected]> Co-authored-by: Claude Fable 5.1 <[email protected]>
nadongjun
pushed a commit
to nadongjun/ray
that referenced
this pull request
Oct 6, 2026
…mmon/ and formats/parquet/ (ray-project#66497) ## Description `python/ray/data/_internal/datasource_v2/` grouped files by role (`listing/`, `scanners/`, `readers/`, `partitioners/`, `chunkers/`), and each role folder mixed the abstract class, the format-independent implementation and the Parquet one. `listing/file_indexer.py` held `FileIndexer` next to `NonSamplingFileIndexer`, with `FooterFileIndexer` two files over. Someone adding a format could not tell from the tree what they must implement, what they may reuse, and what is Parquet's business. This PR regroups the package by kind: `interfaces/` is what a format implements, `common/` is what it may reuse, `formats/<name>/` is one folder per format. `interfaces/` imports nothing else in the package, `common/` imports only `interfaces/`, `formats/` may import both. No class, signature or behaviour changes; every import path changes. ### The layout ``` python/ray/data/_internal/datasource_v2/ __init__.py InputSplit TypeVar (unchanged) README.md new: layout rule, how a read flows, what a format implements interfaces/ abstract classes and the types their signatures use datasource_v2.py DataSourceV2, DatasourceCategory, FileDataSourceV2, DataSourceWithMetadata scanner.py Scanner reader.py Reader file_indexer.py FileIndexer, FileInfo file_pruner.py FilePruner file_partitioner.py FilePartitioner, PartitionHints in_memory_size_estimator.py InMemorySizeEstimator supports_metadata.py SupportsMetadata, MetadataType pushdown.py SupportsFilterPushdown, SupportsColumnPushdown, SupportsLimitPushdown, SupportsPartitionPruning, ListFilesPushdown read_units.py ReadUnit, ReadUnitFragment synthesized_columns.py SynthesizedColumn, ReadUnitPosition file_manifest.py FileManifest, ChunkMetadata, create_chunk_metadata common/ format-independent implementations non_sampling_file_indexer.py NonSamplingFileIndexer listing_utils.py, indexing_utils.py file_pruners.py FileExtensionPruner, PartitionPruner, PartitionPredicatePruner round_robin_partitioner.py RoundRobinPartitioner online_bin_packer.py OnlineBinPacker, BinItem, Bin size_estimators.py SamplingInMemorySizeEstimator file_scanner.py FileScanner arrow_file_scanner.py ArrowFileScanner file_reader.py FileReader synthesized_columns.py PathColumn, RowHashColumn pushdown_utils.py derive_list_files_pushdown, combine_predicates formats/ parquet/ parquet_datasource_v2.py ParquetDatasourceV2 parquet_scanner.py ParquetScanner parquet_file_reader.py ParquetFileReader footer_file_indexer.py FooterFileIndexer footer_reader.py FooterReader actor parquet_footer_types.py RowGroupInfo, FileChunks, ParquetRowGroupChunkMetadata parquet_size_estimator.py ParquetInMemorySizeEstimator parquet_file_chunking_utils.py, parquet_row_group_coalescing.py, parquet_utils.py ``` ### What changes 1. **32 renames** into the three folders; `git diff -M` pairs them, most at 90%+ similarity with the rest being import lines. 2. **7 files split** where an interface sat next to its implementations: `listing/file_indexer.py`, `listing/file_pruners.py`, `readers/in_memory_size_estimator.py`, `readers/synthesized_columns.py`, `logical_optimizers.py` (mixins to `interfaces/pushdown.py`, helpers to `common/pushdown_utils.py`), `chunkers/file_chunker.py` (dissolved into `interfaces/file_manifest.py` and `formats/parquet/parquet_footer_types.py`) and `chunkers/parquet_footer_types.py` (`BinItem`/`Bin` to `common/online_bin_packer.py`). 3. **27 files outside the package** change import lines only: `read_api.py`, the legacy `ParquetDatasource`, logical rules, planners, tests. Tests keep their locations. 4. **Nine type errors fixed** in `common/indexing_utils.py`, `common/non_sampling_file_indexer.py` and `interfaces/file_manifest.py`. These three files were in `ci/lint/pyrefly-excluded-files.txt` under their old paths, so the move puts them under pyrefly for the first time. The fixes: re-raise after `_handle_read_os_error` returns instead of reading an unbound `file_info`; the threaded lister always wraps results in `OrderedFileResult` and unwraps on yield, so `input_path_index` is an `int` and there is no `FileInfo | OrderedFileResult` union; `FileManifest.__init__` asserts a `TableBlockAccessor` before calling `column_names()`. `ci/` is not touched. 5. **`README.md`** (new) for the package. One import still crosses the layering line: `common/online_bin_packer.py` reads and writes `ParquetRowGroupChunkMetadata` from `formats/parquet/`. The packer is meant for any format with sized sub-file units, so it stays in `common/`. A follow-up PR, once ray-project#66121 has settled the packer's fields, adds a generic chunk-run type in `interfaces/` that the packer works on and makes the Parquet type a subclass of it. Doing that here would turn a reviewable set of renames into content changes. ## Additional information Follows ray-project#66450 (`[4/6]`) and ray-project#66478 (`[5/6]`), both merged; the branch sits directly on `master`. Not a duplicate: ray-project#62573 (WIP, `_internal/` wide) does not touch `datasource_v2/`. Checks run locally from this branch (macOS, `~/ray/.venv`): ``` pytest -q tests/unit/datasource_v2 # 146 passed ``` `ruff`, `black` and `pydoclint` at the pre-commit pins are clean on every changed Python file; `tests/test_import.py` (from ray-project#66463) passes; `pyrefly` via `ci/lint/pyrefly-check.sh` reports 59 errors, identical to `master`, none new. Written with Claude Code; I reviewed every changed line and ran the tests above. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Signed-off-by: Aarrya <[email protected]> Co-authored-by: Claude Fable 5.1 <[email protected]>
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.
Description
Partition pruning drops whole files by the partition values in their paths.
It lived on
ArrowFileScanner, so only PyArrow Dataset formats had it, andReadFiles.apply_predicaterequired filter pushdown, so a scanner withoutit never received a predicate at all. Partition values come from paths and
the
Partitioningspec, not from file contents, so the pruning is the samefor every file format. This PR moves it to
FileScannerand lets partitionconjuncts reach a scanner that has nothing else to push.
What changes
scanners/file_scanner.py.FileScannerbecomes aSupportsPartitionPruning. Thepartitioningandpartition_predicatefields and the five pruning members move here from
ArrowFileScannerunchanged.
scanners/arrow_file_scanner.py. Loses them; keeps filter, columnand limit pushdown.
logical/operators/read_operator.py.supports_predicate_pushdownaccepts either mixin. In
apply_predicate, data conjuncts go topush_filtersonly when the scanner has it and otherwise stay in theFilter; when nothing was pushed it returnsselfso the originalFilteris kept.scanner.py,plan_read_files_op.py,file_pruners.pyand
logical_optimizers.pynow nameFileScanner.tests/unit/datasource_v2/test_file_scanner.py(new): a scannerwith no pushdown of its own takes a partition predicate, data conjuncts
stay in a
Filterabove the read, nothing-to-push keeps the originaloperator, listing derives the same pruner as the reader, and
prune_input_splitdrops files by path.flowchart TD P["ReadFiles.apply_predicate(expr)"] --> S["split expr by partition columns"] S -->|partition conjuncts| PP["scanner.prune_partitions"] S -->|data conjuncts, scanner pushes filters| PF["scanner.push_filters"] S -->|data conjuncts, no filter pushdown| F["stay in Filter above the read"] PP --> N{"anything pushed?"} PF --> N N -->|no| K["return self: original Filter kept"] N -->|yes| R["new ReadFiles, residual Filter if any"]ParquetScannerand every otherArrowFileScannerbehave as before: samemembers, inherited one level up.
Additional information
Not a duplicate: no open PR touches partition pruning or the
ReadFilespushdown gate.
Checks run locally from this branch (macOS,
~/ray/.venv):ruff,blackandpydoclintat the pre-commit pins are clean;pyreflyvia
ci/lint/pyrefly-check.shreports 59 errors, identical tomaster, nonenew.
Written with Claude Code; I reviewed every changed line and ran the tests above.
🤖 Generated with Claude Code