Repository navigation
[cherry-pick][2.60.1][Data] Raise an error for Delta tables with column mapping in read_delta (#67895) - #68213
Merged
sai-miduthuri merged 1 commit intoNov 17, 2026
Conversation
…lta (#67895) `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. `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. 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 ``` API (`read_api.read_delta`). 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). 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 - 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]> (cherry picked from commit 3094de2) Signed-off-by: Sai Miduthuri <[email protected]>
Contributor
There was a problem hiding this comment.
Code Review
This pull request adds a check to ray.data.read_delta to reject Delta tables that use column mapping (where delta.columnMapping.mode is set to name or id) by raising a NotImplementedError. It also updates the documentation to reflect this limitation and adds corresponding unit tests to verify the rejection behavior and ensure that tables with a mode of "none" are still read correctly. I have no feedback to provide as there are no review comments.
sai-miduthuri
added a commit
that referenced
this pull request
Nov 17, 2026
…ake file sizes from the log (#67900) (#68214) ## Description Cherry-pick of #67900 (master commit 63ff72c) onto `releases/2.60.1`. **Top of a 2-PR stack on `releases/2.60.1`:** #68213 (the #67895 pick), then this PR. Merging this PR with `gh stack merge` lands both in order. #67900 makes two changes to `read_delta`: - **`partition_filters`.** This new keyword-only parameter takes deltalake's `(column, op, value)` tuples. A flat list is an AND, and a list of lists is an OR of ANDs. Only the matching partitions' files become fragments, so only they are listed and read. Every column must be a partition column. An OR of groups needs deltalake 1.6.6 and raises a clear error on older versions. `read_unity_catalog` passes it through `reader_kwargs`. The default, `None`, keeps the current behavior. - **File sizes from the Delta log.** `ParquetDatasource.from_pyarrow_dataset` takes them as `known_file_sizes` and calls `get_file_info` only for paths missing from it. Before, it made one `get_file_info` request per file. On the 26,085-file table in #67900, that was 26,085 requests before a read started. `read_delta` is the only caller of `from_pyarrow_dataset` on this branch. ## Related issues Related to #67900. ## Additional information ### Cherry-pick details The #67900 commit applied cleanly with `git cherry-pick -x` on top of the #67895 pick. It has the same 3 files, +303/-3, and the same `git patch-id --stable` as the master commit. It needs #68213 because its `read_api.py` hunk sits right after the column-mapping check that #67895 adds. A second commit adds `from unittest import mock` to `test_delta.py`. `test_read_unity_catalog_partition_filters`, which #67900 adds, uses `mock.patch.object`. On master the import comes from #66275, which isn't on this branch, so ruff reports `F405` and the test would fail with a `NameError`. The import sits where master has it. Not a duplicate: neither `releases/2.60.1` nor any open or merged PR against it contains #67900. No open PR on any branch picks it. ### Testing The four suites are `datasource/test_delta.py`, `test_catalog.py`, `datasource/test_write_delta.py` and `unit/datasource/`, under `python/ray/data/tests/`. They're the suites #67900 was tested with on master. `test_catalog.py` skips the whole module without `databricks-sdk`, and this branch's Data CI locks don't include it, so CI skips the file here. I ran it with `databricks-sdk` 0.143.0, in its own pytest process as Bazel would. Sharing a process with the other suites makes 10 of its tests, the ones that start their own Ray cluster, error with "Maybe you called ray.init twice". That happens on `releases/2.60.1` too. The new `read_unity_catalog` test is in `test_delta.py`, so it runs either way. | Command | Result | |---|---| | `pre-commit run` on the 3 changed files | Passed with the `mock` import. Without it, ruff fails with `F405` on `mock` | | `pytest datasource/test_delta.py datasource/test_write_delta.py unit/datasource/`, deltalake 1.5.0 | 214 passed. #68213 alone: 202 passed | | `pytest test_catalog.py`, deltalake 1.5.0, databricks-sdk 0.143.0 | 34 passed, the same as with #68213 alone and on `releases/2.60.1` | | `pytest datasource/test_delta.py`, deltalake 1.5.0 and 1.6.6 | 30 passed on each. #68213 alone: 18 passed. Master has 31 because it also has #66275's test | `test_delta_read_partition_filters_or_groups` covers both deltalake paths. It reads an OR of groups through `file_pruning_predicate` on 1.6.6, and checks the "needs deltalake 1.6.6 or later" error on 1.5.0. The environment was Python 3.12.12 with the Ray 2.60.0 release wheel, which was built from `releases/2.60.0` at b7f4259. This branch's `python/ray/data` and `python/ray/tests` were copied over it. The other packages were pinned to the CI lock: pyarrow 23.0.1, pandas 2.3.3, numpy 2.2.6, fsspec 2023.12.1, and deltalake 1.5.0, or 1.6.6 where noted. `databricks-sdk` 0.143.0 was added for `test_catalog.py`. Building Ray from source for `bazel test` wasn't practical on my machine. An earlier version of this description counted `test_catalog.py` among the suites run. My run had skipped it because `databricks-sdk` wasn't installed. AI assistance was used to prepare this cherry-pick. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Signed-off-by: Abhishek Verma <[email protected]> Signed-off-by: Sai Miduthuri <[email protected]> Co-authored-by: abhishekverma-ray <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
sai-miduthuri
pushed a commit
that referenced
this pull request
Nov 18, 2026
…mn mapping in write_delta (#67898) (#68231) ## 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](https://claude.com/claude-code) Signed-off-by: Abhishek Verma <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
sai-miduthuri
pushed a commit
that referenced
this pull request
Nov 18, 2026
…dentials to the environment (#67899) (#68232) ## Description Backport of #67899 (master commit 596241a) onto `releases/2.60.1`, **AWS part only**. It's based directly on `releases/2.60.1` and is independent of #68213 / #68214 and the #67898 pick; all of them merge with it without conflicts. On this branch, `DatabricksUnityCatalog.resolve()` writes vended AWS credentials into the driver's `os.environ` and, if Ray isn't running yet, starts Ray with them in `runtime_env`. AWS env vars take precedence over the instance role, so after one Unity Catalog read the driver and every worker use a short-lived credential scoped to that one table. Writes to the job's own buckets (checkpoints, logs) then fail with `ACCESS_DENIED`. With this PR, AWS credentials travel only in the objects that use them, which pickle into the read and write tasks: - An explicit `S3FileSystem` for every reader and mode. Before, AWS Parquet reads used the environment. - For Delta, the AWS keys and region in `storage_options`, for deltalake's log read and the `write_delta` commit. `read_delta`, `write_delta` and the datasink's credential refresh already merge `resolved.storage_options` on this branch. GCS was already environment-free and is unchanged. A response with no known credential type still raises `ValueError`. Behavior changes worth a release note (the same as on master): - AWS Parquet reads through Unity Catalog now need `region`, which the `DatabricksUnityCatalog` docstring already lists as required for AWS. - Code that relied on the vended AWS keys being in the environment afterwards no longer gets them. ## Related issues Related to #67899. ## Additional information ### How this differs from #67899 `releases/2.60.1` doesn't have the Azure Unity Catalog work #67899 edits (#66272–#66276: Azure SAS in `storage_options`, `AzureFileSystem` for Parquet, Azurite tests). So `git cherry-pick` conflicts in `catalog.py` and `test_catalog.py` and tries to bring in that Azure code and the Gravitino catalog. I ported the AWS change by hand instead: - **Azure is unchanged.** It still gets the SAS through `_apply_env` (the environment plus `runtime_env`), because nothing else delivers it on this branch. Removing that would break Azure reads. `_creds_to_env` is gone: Azure calls `_parse_azure_creds` directly, and the unknown-type `ValueError` moved into `_resolve_storage`, as on master. - **Not taken:** master's `delta_datasink.py` and `test_write_delta.py` changes. They're comment-only and say Unity Catalog never touches the environment, which is still false for Azure here. `test_catalog_azure.py` doesn't exist on this branch. - **Tests:** master's strict `isolated_env` fixture (environment must come back unchanged, `ray.init` fails if called) covers every AWS and GCS `resolve()` test. The two Azure tests keep the old lenient fixture, renamed `azure_env`. Master deleted `test_resolve_initializes_ray_with_runtime_env`; here it becomes `test_resolve_azure_initializes_ray_with_runtime_env`, since Azure still does that. As on master, `test_resolve_aws_requires_region` covers both readers, and `test_resolve_rejects_unknown_credential_type` and the `storage_options` asserts in the `write_delta` test are added. Not a duplicate: no open or merged PR against `releases/2.60.1` picks #67899. ### Testing `test_catalog.py` skips the whole module without `databricks-sdk`, and this branch's Data CI locks don't include it, so **CI doesn't run these tests here**. I ran them locally: | Command | Result | |---|---| | pre-commit (commit hooks) on the 2 changed files | Passed | | `pytest test_catalog.py` (databricks-sdk 0.143.0) | 36 passed. On `releases/2.60.1`: 34 | | The same with `releases/2.60.1`'s `catalog.py` | 8 failed and 7 fixture errors: every AWS `resolve()` test, the Parquet region check, and the `write_delta` `storage_options` asserts | | `pytest datasource/test_write_delta.py` | 101 passed | | `pytest datasource/test_delta.py` | 15 passed | | `pytest unit/datasource/` | 83 passed | 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. Not checked on a real Databricks workspace, as with #67899 on master. AI assistance was used to prepare this backport; 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]>
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
Cherry-pick of #67895 (master commit 3094de2) onto
releases/2.60.1.Bottom of a 2-PR stack on
releases/2.60.1: this PR, then #68214 (the #67900 pick). Merging #68214 withgh stack mergelands both in order.read_deltareads throughDeltaTable.to_pyarrow_dataset(), which doesn't apply a Delta table's column mapping. A table withdelta.columnMapping.modeset tonameoridstores its columns in the data files under physical names such ascol-<uuid>. With deltalake 1.6.4 to 1.6.6, a reader 2 / writer 5 table passes deltalake's own protocol check, and every mapped column comes back as nulls.ds.schema()still shows the right names, so nothing downstream notices.#67895 makes
read_delta, andread_unity_catalogthrough it, raiseNotImplementedErrorfor these tables before reading. The message names the mode and points to #64854. Tables without column mapping, including an explicitmode = none, read as before.Related issues
Related to #67895. Reading column-mapped tables is tracked in #64854.
Additional information
Cherry-pick details
read_api.pyapplied cleanly withgit cherry-pick -x.test_delta.pyconflicted only on context. On master, the new tests followtest_delta_read_deletion_vectors_message_is_actionable, which #66275 added and which isn't on this branch. I kept only what #67895 adds:import json,_write_column_mapped_table,test_delta_read_rejects_column_mappingandtest_delta_read_column_mapping_mode_none. The added lines are identical to the master commit's, in the same 2 files, +109/-0.Not a duplicate: neither
releases/2.60.1nor any open or merged PR against it contains #67895. No open PR on any branch picks it.Testing
The four suites are
datasource/test_delta.py,test_catalog.py,datasource/test_write_delta.pyandunit/datasource/, underpython/ray/data/tests/. The last three are the other suites #67895 was tested with on master.test_catalog.pyskips the whole module withoutdatabricks-sdk, and this branch's Data CI locks don't include it, so CI skips the file here. I ran it withdatabricks-sdk0.143.0, in its own pytest process as Bazel would. Sharing a process with the other suites makes 10 of its tests, the ones that start their own Ray cluster, error with "Maybe you called ray.init twice". That happens onreleases/2.60.1too.pre-commit runon the 2 changed filespytest datasource/test_delta.py datasource/test_write_delta.py unit/datasource/, deltalake 1.5.0releases/2.60.1without this PR: 199 passedpytest test_catalog.py, deltalake 1.5.0, databricks-sdk 0.143.0releases/2.60.1without this PRpytest datasource/test_delta.py, deltalake 1.5.0 and 1.6.6-k column_mapping) withreleases/2.60.1'sread_api.py, deltalake 1.5.0 and 1.6.6test_delta_read_rejects_column_mapping[name]and[id]fail andtest_delta_read_column_mapping_mode_nonepassesThe environment was Python 3.12.12 with the Ray 2.60.0 release wheel, which was built from
releases/2.60.0at b7f4259. This branch'spython/ray/dataandpython/ray/testswere copied over it. The other packages were pinned to the CI lock: pyarrow 23.0.1, pandas 2.3.3, numpy 2.2.6, fsspec 2023.12.1, and deltalake 1.5.0, or 1.6.6 where noted.databricks-sdk0.143.0 was added fortest_catalog.py. Building Ray from source forbazel testwasn't practical on my machine.An earlier version of this description counted
test_catalog.pyamong the suites run. My run had skipped it becausedatabricks-sdkwasn't installed.AI assistance was used to prepare this cherry-pick.
🤖 Generated with Claude Code