Skip to content

[cherry-pick][2.60.1][Data] Raise an error for Delta tables with column mapping in write_delta (#67898) - #68231

Merged
sai-miduthuri merged 1 commit into
ray-project:releases/2.60.1from
abhishekverma-ray:abhishekverma/cherry-pick-67898-2.60.1
Nov 18, 2026
Merged

sai-miduthuri merged 1 commit into
ray-project:releases/2.60.1from
abhishekverma-ray:abhishekverma/cherry-pick-67898-2.60.1

Conversation

@abhishekverma-ray

@abhishekverma-ray abhishekverma-ray commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Description

Cherry-pick of #67898 (master commit 1b7a10c) onto releases/2.60.1.

This was first stacked on #68213 (the #67895 pick), because #67898 moves the _write_column_mapped_table test helper that #67895 added to test_delta.py into a shared ray/data/tests/delta_test_utils.py. #68213 and #68214 are merged now, so this PR is rebased onto releases/2.60.1. The rebase had no conflicts.

write_delta writes Parquet files with the table's column names. A column-mapped Delta table (delta.columnMapping.mode = name or id) stores columns under physical names, so engines that apply the mapping (Databricks, Spark) read every column of those files as null. deltalake 1.6.6 commits such files; 1.5.0 refuses only after the data files are written.

#67898 makes write_delta raise NotImplementedError for an existing table with column mapping, for both APPEND and OVERWRITE. It checks in on_write_start (nothing is written) and again at commit (on_write_start doesn't run for an empty dataset, and an empty OVERWRITE still commits). Tables with mode = none and new tables write as before.

Related issues

Related to #67898 and #67895. Column mapping support is tracked in #64854.

Additional information

Cherry-pick details

git cherry-pick -x on top of #68213. delta_datasink.py, test_write_delta.py and the new delta_test_utils.py applied cleanly. test_delta.py conflicted only on context: on master the removed helper sits next to test_delta_read_deletion_vectors_message_is_actionable, which isn't on this branch. I removed the helper and didn't add that test. The result matches the master commit: the same 4 files, +164/-68.

Not a duplicate: no open or merged PR against releases/2.60.1 picks #67898.

Testing

Command Result
pre-commit (commit hooks) on the 4 changed files Passed
pytest datasource/test_write_delta.py 105 passed. On #68213 without this PR: 101
pytest datasource/test_delta.py 30 passed (18 from before #68214, plus #68214's new tests)
pytest test_catalog.py (databricks-sdk 0.143.0) 34 passed
pytest unit/datasource/ 83 passed
The 4 new tests (-k column_map) with #68213's delta_datasink.py 3 fail; the mode = none case passes, as it should

The four pytest rows were rerun after the rebase onto releases/2.60.1 (375b268). The revert check ran before the rebase, and the rebase didn't change this PR's diff. Each file ran in its own pytest process. Environment: Python 3.12.10 with the Ray 2.60.0 release wheel, this branch's python/ray/data and python/ray/tests linked over it, and the CI lock pins: pyarrow 23.0.1, pandas 2.3.3, numpy 2.2.6, deltalake 1.5.0, pytest 7.4.4.

AI assistance was used to prepare this cherry-pick; every line has been reviewed by the submitter.

🤖 Generated with Claude Code

@abhishekverma-ray
abhishekverma-ray marked this pull request as ready for review November 17, 2026 04:01
@abhishekverma-ray
abhishekverma-ray requested a review from a team as a code owner November 17, 2026 04:01
@abhishekverma-ray abhishekverma-ray added data Ray Data-related issues go add ONLY when ready to merge, run all tests labels Nov 17, 2026

@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 validation to prevent writing to Delta tables that use column mapping, which is currently unsupported by Dataset.write_delta. The DeltaDatasink has been updated to fetch full table metadata and check for column mapping at both the start and completion of a write. Additionally, the write_column_mapped_table helper was moved to a shared test utility file, and new unit tests were added to verify this rejection behavior. There are no review comments, so I have no feedback to provide.

@rayhhome rayhhome 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.

LGTM!

@sai-miduthuri
sai-miduthuri deleted the branch ray-project:sai-miduthuri/cherry-pick-67895-2.60.1 November 17, 2026 23:49
@abhishekverma-ray
abhishekverma-ray changed the base branch from sai-miduthuri/cherry-pick-67895-2.60.1 to releases/2.60.1 November 18, 2026 00:02
…elta (ray-project#67898)

`write_delta` now raises a clear `NotImplementedError` for an existing
Delta table with column mapping, instead of committing data files that
engines applying the mapping read as nulls. Write-side counterpart of
test helper into a shared `ray/data/tests/delta_test_utils.py`.

`write_delta` writes Parquet files with the table's column names and
commits them with deltalake. A column-mapped table
(`delta.columnMapping.mode` = `name` or `id`) stores its columns in data
files under physical names such as `col-<uuid>`, or field ids, which
only the Delta log maps to the column names. Engines that apply the
mapping (Databricks, Spark) therefore read every column of the newly
written files as null. The commit is permanent: the bad files stay in
the table's log until someone rewrites them.

What happens depends on the deltalake version, checked with a hand-built
column-mapped table:

| deltalake | reader 2 / writer 5, `mode=name` | reader 3 / writer 7,
`mode=name` |
|---|---|---|
| 1.5.0 (Ray CI) | commit refused: `Unsupported table features required:
[ColumnMapping]` (after the data files are written) | refused |
| 1.6.6 | **commit succeeds**; the new file stores `id` instead of the
physical name `col-a1` | **commit succeeds** |

When the target table exists and `delta.columnMapping.mode` is anything
but `none`, `write_delta` raises `NotImplementedError` naming the mode
and pointing to ray-project#64854, for both `APPEND` and `OVERWRITE`:

- `on_write_start` checks, so no data file is written and nothing is
committed. It already reads the table's metadata there to check
`partition_by`; that read now returns the whole `Metadata`.
- The commit checks again, because `on_write_start` doesn't run for an
empty dataset, and an empty `OVERWRITE` still commits.

Tables with `mode = none` (or no property) and new tables write as
before.

```mermaid
flowchart TD
    subgraph Before
        subgraph BS[Subsystem: IO]
            subgraph BC["Component: DeltaDatasink (delta_datasink.py)"]
                B1["on_write_start: read partition columns"] --> B2["write: Parquet files with column names"]
                B2 --> B3["on_write_complete: commit"]
            end
        end
    end
    subgraph After
        subgraph AS[Subsystem: IO]
            subgraph AC["Component: DeltaDatasink (delta_datasink.py)"]
                A1["on_write_start: read metadata"] --> A0{"delta.columnMapping.mode<br/>!= none?"}
                A0 -->|yes| AE["NotImplementedError (ray-project#64854)"]
                A0 -->|no| A2["write: Parquet files"]
                A2 --> A3{"commit: column mapping?<br/>(also covers empty writes)"}
                A3 -->|yes| AE
                A3 -->|no| A4["commit (unchanged)"]
            end
        end
    end
    classDef added fill:#c8e6c9,stroke:#2e7d32,color:#000
    classDef changed fill:#fff9c4,stroke:#f9a825,color:#000
    class A0,A3,AE added
    class A1 changed
```

IO (`_internal/datasource/delta_datasink.py`).

No open PR covers this. ray-project#67895 adds the same guard to `read_delta`; this
PR covers writes and doesn't overlap with it.

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_write_delta.py`: 105
passed on deltalake 1.5.0, and 105 passed with deltalake 1.6.6 on the
path. deltalake can't write a column-mapped table (it stores the
property but keeps the column names in the data files), so the shared
helper `write_column_mapped_table` (moved from ray-project#67895's `test_delta.py`
into `ray/data/tests/delta_test_utils.py`) writes the `_delta_log` of a
reader 2 / writer 5 table by hand, with the data file storing the column
under a physical name:
- Appending to a `name` or `id` table raises `NotImplementedError`
naming the mode and ray-project#64854, with no new data file and no new log
version.
- An empty `OVERWRITE` raises at commit time and leaves the log
unchanged.
  - A table written with `mode = none` appends as before.
  - A missing configuration or an empty mode counts as `none`.
- Without the check, the 3 rejection tests fail on deltalake 1.5.0
(deltalake refuses the commit only after the files are written) and on
1.6.6 (the commit succeeds); the `mode = none` test passes either way.
- `test_delta.py`: 19 passed on 1.5.0 and 1.6.6, with the shared helper.
- `test_write_delta_catalog_e2e.py` needs the local moto S3 server,
which isn't available here.
- 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]>
(cherry picked from commit 1b7a10c)
Signed-off-by: Abhishek Verma <[email protected]>
@abhishekverma-ray
abhishekverma-ray force-pushed the abhishekverma/cherry-pick-67898-2.60.1 branch from a766279 to 869d59c Compare November 18, 2026 00:03
@sai-miduthuri
sai-miduthuri enabled auto-merge (squash) November 18, 2026 00:07
@sai-miduthuri
sai-miduthuri merged commit a06ad1f into ray-project:releases/2.60.1 Nov 18, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

data Ray Data-related issues go add ONLY when ready to merge, run all tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants