Repository navigation
Conversation
Signed-off-by: jiangxt2 <[email protected]>
Signed-off-by: jiangxt2 <[email protected]>
Signed-off-by: jiangxt2 <[email protected]>
There was a problem hiding this comment.
Code Review
This pull request introduces support for custom path column names when using include_paths with DataSourceV2 in Ray Data. It allows include_paths to accept a string representing the custom column name, updates the PathColumn class to support this name, and adds validation to prevent conflicts with partition columns or row_hash. Additionally, it updates read_parquet and includes comprehensive unit tests. The review feedback highlights a potential schema mismatch if RowHashColumn collides with an existing file column, suggesting that the reordering logic applied to PathColumn should also be extended to RowHashColumn.
Signed-off-by: jiangxt2 <[email protected]>
Preserve full-schema inference and projection coverage while rejecting custom path names that collide with generated checkpoint ID columns. Signed-off-by: jiangxt2 <[email protected]>
Limit the documented rejection rules to non-default custom path names. Signed-off-by: jiangxt2 <[email protected]>
Preserve custom Parquet path columns while adopting plan-time checkpoint generated ID binding and its collision validation. Signed-off-by: jiangxt2 <[email protected]>
Preserve upstream columns validation and filesystem retries alongside custom Parquet path column projection and checkpoint coverage. Signed-off-by: jiangxt2 <[email protected]>
|
This pull request has been automatically marked as stale because it has not had You can always ask for help on our discussion forum or Ray's public slack channel. If you'd like to keep this open, just leave any comment, and the stale label will be removed. |
Preserve custom path collision checks while adopting upstream partition value helpers for file readers. Signed-off-by: jiangxt2 <[email protected]>
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
Signed-off-by: jiangxt2 <[email protected]>
|
Thanks for these! The team is aligning on some Ray Data test conventions (#67919 / #67928). In short: each test should fail if the change is reverted, extend or parametrize existing tests before adding new ones, test through the public read_* APIs rather than asserting on internal mock calls, and use ray_start_regular_shared instead of starting new clusters. This PR has about 2.4× more test lines than code. Could you trim it to the tests that catch a revert, and note in the description which revert each one catches? |
## Description
Fix DataSourceV2 filters on synthesized columns such as `path`,
preventing incorrect partition pruning and Arrow field-binding errors.
**Before:** A `path` predicate could use a same-named Hive partition
value or reach the physical Arrow scan.
**After:** Enabled synthesized columns are excluded from
partition-column classification. Arrow-backed scanners push safe
physical predicates and retain synthesized or mixed predicates as
residual filters. MCAP uses the same partition classification. Existing
scanner fields and constructor signatures are preserved.
**Subsystems:** IO; logical planning / query optimization (regression
coverage).
```mermaid
flowchart LR
subgraph Before["Before — IO: Arrow-backed scanner"]
B1["path predicate"] --> B2["Partition pruning or Arrow scan"]
B2 -->|Incorrect pruning or binding| B3["Incorrect result or error"]
end
subgraph After["After — IO: Arrow-backed scanner"]
A1["Classify predicate"] -->|Physical predicate| A2["Arrow scan"]
A1 -.->|Synthesized or mixed predicate| A4["Residual Filter"]
A2 --> A3["Reader adds synthesized columns"]
A3 -->|Residual present| A4
A3 -->|No residual| A5["Output"]
A4 --> A5
end
classDef changed fill:#fff9c4,stroke:#f9a825,color:#000
classDef error fill:#ffcdd2,stroke:#c62828,color:#000
class B2,A1,A4 changed
class B3 error
```
## Related issues
Fixes #66916. Related to #66572.
#66572 is open and proposes configurable Parquet path-column names and
same-named file-column projection fixes; this PR addresses
synthesized-column predicate classification and filtering.
## Additional information
**Testing:** These selections passed on Linux ARM64 with Python 3.12 and
PyArrow 23.0.1, using Ray `a9843db` native binaries and source with this
PR’s Python changes applied. Environment and reporting options are
omitted.
```bash
python -m pytest -q python/ray/data/tests/unit/datasource_v2/test_arrow_file_scanner.py::test_push_filters_retains_synthesized_residual python/ray/data/tests/unit/datasource_v2/test_file_scanner.py::test_partition_columns_exclude_enabled_synthesized_columns # 18 passed
python -m pytest -q python/ray/data/tests/test_predicate_pushdown.py::test_synthesized_path_filters_use_output_values python/ray/data/tests/test_predicate_pushdown.py::test_synthesized_path_residual_preserves_read_constraints # 5 passed
python -m pytest -q python/ray/data/tests/datasource/test_orc.py::test_read_orc_v2_filter_path_from_directory # 1 passed
python -m pytest -q 'python/ray/data/tests/datasource/test_mcap.py::test_read_mcap_v2_filter_path_over_same_named_partition[v2]' # 1 passed
```
**Revert checks:** The FileScanner, MCAP, and Hive Parquet cases catch
the partition-classification revert. The Arrow Scanner, ORC directory,
unpartitioned Parquet, and residual-plan cases catch the Arrow-pushdown
revert; ORC inherits that implementation during this check. Every
selected case also fails when all three production changes are reverted.
Synthesized-column residual filters run after reading and can reduce
pruning and early-limit opportunities. Broader same-named
physical-column projection behavior is outside this fix.
Codex AI assistance was used for implementation, validation, and review.
---------
Signed-off-by: jiangxt2 <[email protected]>
Signed-off-by: jiangxt2 <[email protected]>
Signed-off-by: jiangxt2 <[email protected]>
Signed-off-by: jiangxt2 <[email protected]>
Signed-off-by: jiangxt2 <[email protected]>
Signed-off-by: jiangxt2 <[email protected]>
Signed-off-by: jiangxt2 <[email protected]>
Description
Before: DataSourceV2 uses a fixed
pathcolumn; projection can return a same-named file column, and incompatible physical types can cause schema merging to fail.After: DataSourceV2 callers can choose the synthesized path column name in
read_parquetby passing a nonempty string toinclude_paths, for exampleray.data.read_parquet(path, include_paths="source_file"). The synthesized column overwrites a same-named file column, including when projected, and the inferred schema order matches emitted tables.Nonempty string names require DataSourceV2; V1 rejects them with
NotImplementedErrorinstead of silently usingpath. Boolean usage remains supported.Reject non-default path names that conflict with partition columns or an enabled
row_hashcolumn. Path column names must also remain distinct from active checkpoint-generated ID columns.Ignore overwritten path fields when merging file schemas, while retaining errors for incompatible types in other fields.
Related issues
Related to #63757
This PR adds configurable Parquet path-column names; #67079 separately addresses synthesized-column filtering.
Additional information
The change is limited to Parquet DataSourceV2 and shared synthesized-column reader behavior; other public file-reading API signatures are unchanged.
DeveloperAPI compatibility: subclasses of
PathColumnthat previously overrode thenameclass attribute and used a no-argument constructor must pass the name explicitly or adapt their constructor.The API shape follows maintainer feedback in #63758 to accept the name through
include_paths, and builds on the sharedSynthesizedColumnabstraction from #66390.The upstream synthesized-column filtering fix (#67079) keeps path predicates as residual filters, evaluated after path synthesis.
Subsystems
API (
read_api.py) and IO (_internal/datasource_v2/).Data flow
flowchart LR A["API: read_parquet"] --> B["IO: infer file schemas"] B --> C["Exclude overwritten path field"] C --> D["Merge and augment schema"] D --> E["IO: read file columns"] E --> F["Append synthesized path"]Testing
Latest validation:
Python 3.12.14 and PyArrow 23.0.1.
its 8-file cumulative scope.
Regression coverage:
The list describes coverage in the suite; only the pytest command below
was rerun against the current code state.
Unless otherwise noted, test names below use the
test_read_parquet_v2_prefix:include_pathscatches failed default-path replacement across incompatiblephysical types;
custom_path_column_preserves_file_columncatches incorrectcustom paths or filters, schema merge failures and loss of the physical
path.path_overrides_only_file_column: catches lost rows when no physicalcolumns remain.
path_does_not_hide_other_schema_conflicts: catches suppression of type errors in non-overwritten fields.test_read_parquet_v2_rejects_invalid_columnscatches acceptance of emptynames or row-hash conflicts;
test_read_parquet_v1_rejects_new_paramscatchesV1 accepting a string name;
test_custom_path_column_rejects_partition_namecatches partition conflicts during scanner creation and reading.
test_include_paths_with_column_projectioncatches loss of the defaultpath with
columns=;test_include_row_hash_existing_column_with_projectioncatches schema/batch order mismatches or changed projected hashes.
test_read_parquet_adds_generated_id_columncatches missing custom pathsor invalid generated IDs;
test_read_parquet_path_conflicts_with_generated_idcatches accepted ID-name conflicts, with configuration before and after reading.
test_merge_file_schemas_transforms_before_merging: checks that the transform runs before merging and preserves schema metadata.test_push_filters_retains_synthesized_residual: catches failure to retainsynthesized-column predicates as residual filters.
The retained tests do not cover transform forwarding on the distributed full-schema path.
Command for the 4 passing cases
Run inside the Linux ARM64 container, with the worktree mounted at
/worktreeand test dependencies onPYTHONPATH=/deps:Codex and Claude AI assistance was used to implement and validate this change.