Skip to content

[data] Fix delta column mapping read - #64929

Closed
n3sfan wants to merge 6 commits into
ray-project:masterfrom
n3sfan:fix/delta-column-mapping-read
Closed

n3sfan wants to merge 6 commits into
ray-project:masterfrom
n3sfan:fix/delta-column-mapping-read

Conversation

@n3sfan

@n3sfan n3sfan commented Jul 22, 2026 •

Copy link
Copy Markdown

Description

Fix ray.data.read_delta() for flat Delta tables using delta.columnMapping.mode = name.

When delta-rs cannot create a PyArrow dataset because column mapping is unsupported, Ray now builds a dataset from active Delta Add actions, 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 - passed
  • python -m pytest -q python/ray/data/tests/datasource/test_delta.py - passed
    • Real Databricks Unity Catalog test passed

AI assistance used. Human reviewed all changed lines and validation results.

n3sfan added 2 commits July 22, 2026 16:50
Fallback when delta-rs cannot build a PyArrow dataset for
  column-mapped tables.

Signed-off-by: n3sfan <[email protected]>
@n3sfan
n3sfan requested a review from a team as a code owner July 22, 2026 13:44

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread python/ray/data/read_api.py Resolved
Comment thread python/ray/data/read_api.py Resolved
Comment thread python/ray/data/read_api.py Resolved
Comment thread python/ray/data/read_api.py Resolved

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit cf62107. Configure here.

Comment thread python/ray/data/read_api.py Resolved
@n3sfan n3sfan changed the title Fix/delta column mapping read [data] Fix delta column mapping read Jul 22, 2026
@ray-gardener ray-gardener Bot added data Ray Data-related issues community-contribution Contributed by the community labels Jul 22, 2026
@richardliaw richardliaw added the go add ONLY when ready to merge, run all tests label Jul 28, 2026
tobby168 added a commit to tobby168/ray that referenced this pull request Aug 8, 2026
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]>
@n3sfan

n3sfan commented Aug 11, 2026 •

Copy link
Copy Markdown
Author

I have merged with base branch, please review it. Thanks!

@github-actions

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had
any activity for 14 days. It will be closed in another 14 days if no further activity occurs.
Thank you for your contributions.

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.

@github-actions github-actions Bot added the stale The issue is stale. It will be closed within 7 days unless there are further conversation label Aug 26, 2026
@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown

This pull request has been automatically closed because there has been no more activity in the 14 days
since being marked stale.

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!

@github-actions github-actions Bot closed this Sep 9, 2026
goutamvenkat-anyscale pushed a commit that referenced this pull request Nov 9, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-contribution Contributed by the community data Ray Data-related issues go add ONLY when ready to merge, run all tests stale The issue is stale. It will be closed within 7 days unless there are further conversation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Data] ray.data.read_delta silently drops columns on Delta tables with column mapping enabled

2 participants