Repository navigation
Conversation
Signed-off-by: n3sfan <[email protected]>
Fallback when delta-rs cannot build a PyArrow dataset for column-mapped tables. Signed-off-by: n3sfan <[email protected]>
There was a problem hiding this comment.
Code Review
This pull request introduces a temporary compatibility adapter to support reading name-mapped Delta tables in Ray Data, handling physical-to-logical column name mappings, partition columns, and schema evolution. The review feedback highlights several critical runtime issues in the new adapter: a potential ArrowInvalid exception when parsing string partition values into non-string PyArrow scalars, a missing import of ray.util.client that will raise an AttributeError, a potential AttributeError if field.metadata is None, and the need to include array types in the nested column validation check.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Reviewed by Cursor Bugbot for commit cf62107. Configure here.
Signed-off-by: n3sfan <[email protected]>
Signed-off-by: n3sfan <[email protected]>
Signed-off-by: n3sfan <[email protected]>
Under `delta.columnMapping.mode`, a table's Parquet files carry generated column names and the logical names live only in the transaction log. The V2 path opens those files directly with the logical schema, so it would ask for names the files don't have and hand back empty columns. Route such tables to the V1 path instead of guarding against them. Today `to_pyarrow_dataset` raises for them, so behavior is unchanged; if ray-project#64929 lands, they pick up its fix without this path needing to know about it. Co-Authored-By: Claude Opus 5 <[email protected]> Signed-off-by: tobby168 <[email protected]>
|
I have merged with base branch, please review it. Thanks! |
|
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. |
|
This pull request has been automatically closed because there has been no more activity in the 14 days Please feel free to reopen or open a new pull request if you'd still like this to be addressed. Again, you can always ask for help on our discussion forum or Ray's public slack channel. Thanks again for your contribution! |
…lta (#67895) ## Summary `read_delta` (and `read_unity_catalog`, which calls it) now raises a clear `NotImplementedError` for Delta tables with column mapping instead of returning nulls for their columns. This is a stopgap for a patch release; reading these tables is tracked in #64854. ## Before `read_delta` reads through `DeltaTable.to_pyarrow_dataset()`, which gives PyArrow the table's column names but the raw Parquet files. A column-mapped table (`delta.columnMapping.mode` = `name` or `id`) stores its columns there under physical names such as `col-<uuid>`, which only the Delta log maps to the column names. PyArrow finds none of them and fills them with nulls, while `ds.schema()` still shows the right names, so nothing downstream notices. What happens depends on the deltalake version and the table's protocol: | Table | deltalake ≤ 1.6.3 | deltalake 1.6.4 – 1.6.6 | |---|---|---| | reader 2 / writer 5 (no reader features) | `DeltaProtocolError` about reader versions | **every mapped column silently null** | | reader 3 with the `columnMapping` feature | `DeltaProtocolError` | `DeltaProtocolError` | A user hit the silent case on a reader 2 / writer 5 table: two columns with 326,733 and 80,543 non-null values in one file came back with none. ## After Before calling `to_pyarrow_dataset()`, `read_delta` raises `NotImplementedError` when `delta.columnMapping.mode` is anything but `none`. It checks the table property, not the protocol, because reader 2 / writer 5 tables declare no reader features. The message names the mode, explains that the data files use physical column names, and points to #64854. Tables without column mapping, including an explicit `mode = none`, read as before. ```mermaid flowchart TD subgraph Before subgraph BS[Subsystem: API] subgraph BC["Component: read_delta (read_api.py)"] B1["DeltaTable(path, version)"] --> B2["to_pyarrow_dataset()"] B2 --> B3["ParquetDatasource: mapped columns read as nulls"] end end end subgraph After subgraph AS[Subsystem: API] subgraph AC["Component: read_delta (read_api.py)"] A1["DeltaTable(path, version)"] --> A0{"delta.columnMapping.mode<br/>!= none?"} A0 -->|yes| AE["NotImplementedError (#64854)"] A0 -->|no| A2["to_pyarrow_dataset()"] A2 --> A3["ParquetDatasource (unchanged)"] end end end classDef added fill:#c8e6c9,stroke:#2e7d32,color:#000 class A0,AE added ``` ## Subsystems API (`read_api.read_delta`). ## Not a duplicate No open PR covers this. #64929 tried to read column-mapped tables and was closed without merging; this PR only stops the wrong results until that support exists (#64854). ## Testing macOS / Python 3.12, env pinned to the CI lock (pyarrow 23.0.1, deltalake 1.5.0): - `pytest python/ray/data/tests/datasource/test_delta.py`: 19 passed. deltalake can't write a column-mapped table (it stores the property but keeps the logical column names), so the new tests write the `_delta_log` of a reader 2 / writer 5 table by hand, with the data file storing the column under a physical name: - `name` and `id` raise `NotImplementedError` naming the mode and #64854. - A table written with `mode = none` still reads. - A missing configuration or an empty mode counts as `none`. - The same file with deltalake 1.6.6 on the path: 19 passed. Without the check, both error tests fail on deltalake 1.5.0 and on 1.6.6 (where the read succeeds with nulls). - A direct check of the reader 2 / writer 5 `mode = name` table: on deltalake 1.6.6, `to_pyarrow_dataset()` returns `[None, None]` and `read_delta` now raises; on 1.6.3, deltalake raised `DeltaProtocolError` and `read_delta` now raises its clearer error first. - `test_catalog.py`: 46 passed; `test_write_delta.py`: 101 passed. - pre-commit, pyrefly (CI file set) and the API param coverage check pass. AI assistance was used (Claude Code); every line has been reviewed by the submitter. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Signed-off-by: Abhishek Verma <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>

Description
Fix
ray.data.read_delta()for flat Delta tables usingdelta.columnMapping.mode = name.When delta-rs cannot create a PyArrow dataset because column mapping is unsupported, Ray now builds a dataset from active Delta
Addactions, reads physical Parquet columns, and restores logical column names.This preserves logical projection, partition values, multi-file reads, and schema-evolution null filling. ID mapping and nested mapping remain explicitly unsupported.
Adds local protocol-correct coverage plus an opt-in Unity Catalog integration test. The Databricks test runs only when credentials and a disposable name-mapped table are supplied through environment variables.
Related issues
Closes #64854.
Additional information
Validation
ruff check python/ray/data/read_api.py python/ray/data/tests/datasource/test_delta.py- passedpython -m pytest -q python/ray/data/tests/datasource/test_delta.py- passedAI assistance used. Human reviewed all changed lines and validation results.