Repository navigation
[Data][Delta DSv2][11/11] Read Delta Lake tables with v2 checkpoints through DataSourceV2 - #68287
Open
abhishekverma-ray wants to merge 1 commit into
Open
abhishekverma-ray wants to merge 1 commit into
abhishekverma-ray wants to merge 1 commit into
Conversation
Contributor
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
Contributor
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
abhishekverma-ray
force-pushed
the
abhishek/delta-dsv2-8-v2-checkpoint
branch
from
November 18, 2026 04:36
246c47a to
dddb539
Compare
6 of 30 tasks
abhishekverma-ray
force-pushed
the
abhishek/delta-dsv2-8-v2-checkpoint
branch
from
November 19, 2026 03:48
dddb539 to
6350227
Compare
abhishekverma-ray
force-pushed
the
abhishek/delta-dsv2-8-v2-checkpoint
branch
from
November 19, 2026 04:23
6350227 to
9fed2b3
Compare
abhishekverma-ray
force-pushed
the
abhishek/delta-dsv2-8-v2-checkpoint
branch
from
November 19, 2026 04:49
9fed2b3 to
c288bac
Compare
abhishekverma-ray
force-pushed
the
abhishek/delta-dsv2-8-v2-checkpoint
branch
from
November 20, 2026 17:28
c288bac to
6d0e9e0
Compare
This was referenced Nov 20, 2026
abhishekverma-ray
force-pushed
the
abhishek/delta-dsv2-8-v2-checkpoint
branch
2 times, most recently
from
November 23, 2026 10:26
192ca54 to
5800871
Compare
sampan-s-nayak
pushed a commit
that referenced
this pull request
Nov 23, 2026
…68282) ## Summary Adds `DeltaDatasourceV2` and `DeltaScanner`, the DataSourceV2 datasource for one version of a Delta Lake table. Third part of the split of #67676. `read_delta` starts using it in #68283. Replaces #67889, which was opened from a fork; earlier review is there. This PR is part of a GitHub stack, so its diff shows only this layer. ## Before No DataSourceV2 datasource for Delta. ## After - `DeltaDatasourceV2(DataSourceWithMetadata)`: the driver pins the version and takes the schema and partition columns from the log. The file list is built from the log in a Ray task, not on the driver; deltalake 1.6 and later load it when the table is opened anyway (`without_files` is ignored there). `_get_file_indexer()` returns the `DeltaFileIndexer` from #67888, and `get_file_partitioner()` the shared row-group bin packer from #67887. #68407 opens the table only once, in a Ray task. - `DeltaScanner(ParquetScanner)`: data files are Parquet, so filter, column and limit pushdown are inherited. Partition columns keep their place in the output; an `include_paths` `path` column comes last, as with the V1 reader. - Partition values come from the log, not the paths (#67888): `DeltaScanner` prunes partitions with `DeltaPartitionPruner`, which the listing applies to each file's values, and reads with `DeltaFileReader`, a `ParquetFileReader` that takes each file's values from the manifest's `__delta_partition_values` column. `ParquetScanner` gets a `reader_class` class attribute so the scanner can swap the reader without copying `create_reader`. - Everything is read through a filesystem rooted at the table directory, as `DeltaTable.to_pyarrow_dataset` does: the caller's, or `deltalake`'s `DeltaStorageHandler` built from `storage_options`. Credentials and `az://` behave as in V1. - Data files are opened with their sizes from the log, so S3 gets no HEAD request per open: - With `deltalake`'s filesystem, `DeltaTableFileSystemHandler` wraps `DeltaStorageHandler`. The listing gives it every file's size before the footer reads, and `DeltaFileReader` gives it each manifest's sizes. It builds the deltalake handler on first use. - With a caller's `SubTreeFileSystem` over S3 (what `read_unity_catalog` passes), `filesystem_for_sized_opens` now unwraps it, as it already did a plain `S3FileSystem`. - `count()` takes each file's row count from the log (`numRecords`), not from its Parquet footer: the whole-file listing that `count()` uses carries the counts in a `__delta_num_records` manifest column, and `DeltaFileReader.read_metadata` reads a footer only for a file whose writer recorded no stats. Tables with deletion vectors, whose counts include deleted rows, never reach this reader. - `delta_datasource_v2_unsupported_reason()` says when a table must stay on the V1 reader: reader features beyond `timestampNtz` (deletion vectors, ...), column mapping, a partition column type whose values don't round-trip through a string (binary, ...), PyArrow scan options, or a table `path` column with `include_paths`. It fails closed. V1 reads some of these tables; it rejects the others (column mapping, deletion vectors) with the same error as before. #68408 replaces this fallback with errors, before #68286 makes V2 the default. - `generated_id_column` rejects Delta reads for now (#68285 adds support). - The pickle gate scan allowlists `delta_datasource_v2.py`: its only match is a schema `.to_arrow()`; data files are read and gated in `ParquetFileReader`. ```mermaid flowchart LR subgraph IO["Subsystem: IO"] subgraph D["Component: datasource_v2/formats/delta"] DS["driver: DeltaDatasourceV2<br/>log schema, pinned version"] --> IX["DeltaFileIndexer (2/11)"] DS --> BP["make_row_group_bin_packer (1/11)"] DS --> SC["DeltaScanner → DeltaFileReader<br/>partition values from the manifest,<br/>table-rooted filesystem"] end end classDef added fill:#c8e6c9,stroke:#2e7d32,color:#000 class DS,SC added ``` ## Subsystems IO (`_internal/datasource_v2/formats/delta/`; `ParquetScanner.reader_class`; `filesystem_for_sized_opens` in `_internal/util.py`). Ripple: logical planning (`bind_generated_id_column.py` rejects Delta scanners). ## Not a duplicate Split out of #67676, which takes over #65142 (tobby168, credited as co-author). No other open PR reads Delta through DSv2. ## Testing Same env as #67887: - `pytest python/ray/data/tests/unit/datasource_v2/test_delta_datasource_v2.py`: 20 passed. It covers: - the schema and partitioning from the log, and version pinning; - column order and `path` placement, and unknown-column errors; - pickling the indexer and scanner, and reading through the unpickled reader: each row gets its file's partition values from the log, and every data file opens with its size from the log (fails if the reader doesn't pass the sizes, or if two files' partition values are swapped); - `count()`'s row counts: from the log with no file opened, and from the footers when the log has no counts (with the reader change reverted, the first case opens all 3 files and fails); - every fallback reason, and a real table passing the eligibility check; - the `generated_id_column` rejection. - `pytest python/ray/data/tests/unit/datasource_v2/`: 1546 passed (rerun after the review round in a fresh env with the Nov 18 Ray nightly and CI pins). At the top of the stack (#68287), after the `count()` change: unit 1740 passed, `test_delta.py` and `test_delta_v2.py` 138 passed, 1 skipped. I skipped `test_text_datasource_v2.py`, which master added this week and which needs `snappy`, not installed locally. - `tests/unit/datasource/` (pickle gate scan): 125 passed. - `pytest python/ray/data/tests/test_util.py`: 51 passed, including `filesystem_for_sized_opens` on a `SubTreeFileSystem` over S3. - The S3 request count is tested end to end in #68283. - pre-commit and pyrefly (CI file set) 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: tobby168 <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
sampan-s-nayak
force-pushed
the
abhishek/delta-dsv2-8-v2-checkpoint
branch
from
November 23, 2026 11:13
5800871 to
dc3f33a
Compare
abhishekverma-ray
force-pushed
the
abhishek/delta-dsv2-8-v2-checkpoint
branch
from
November 23, 2026 14:41
dc3f33a to
9c67a74
Compare
abhishekverma-ray
force-pushed
the
abhishek/delta-dsv2-8-v2-checkpoint
branch
from
November 24, 2026 03:09
9c67a74 to
9426f80
Compare
abhishekverma-ray
force-pushed
the
abhishek/delta-dsv2-8-v2-checkpoint
branch
from
November 24, 2026 05:57
9426f80 to
06914fc
Compare
abhishekverma-ray
force-pushed
the
abhishek/delta-dsv2-8-v2-checkpoint
branch
from
November 25, 2026 02:54
06914fc to
c7b77b6
Compare
Databricks turns on the v2Checkpoint reader feature for new tables by default. The V1 reader's to_pyarrow_dataset refuses such tables, and the V2 reader fell back to V1 because it didn't list the feature as supported, so neither reader could read them. v2Checkpoint only changes how the log is stored: checkpoints can list the data files in sidecar files, which deltalake replays when it lists the add actions. The V2 reader now accepts the feature. A new test builds a table whose files are listed only in a v2 checkpoint's sidecar and reads it, with and without log-statistics pruning. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Abhishek Verma <[email protected]>
abhishekverma-ray
force-pushed
the
abhishek/delta-dsv2-8-v2-checkpoint
branch
from
November 26, 2026 03:34
c7b77b6 to
df99b8d
Compare
This branch has not been deployed
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.
Summary
The DataSourceV2 Delta reader now accepts the
v2Checkpointreader feature. Databricks turns it on for new tables by default, and until now neither Ray reader could read those tables.Replaces #68197, which was opened from a fork; earlier review is there. This PR is part of a GitHub stack, so its diff shows only this layer.
Before
v2Checkpointas unsupported and fell back to V1.DeltaTable.to_pyarrow_dataset()refuses the table:DeltaProtocolError: The table has set these reader features: {'v2Checkpoint'} but these are not yet supported by the deltalake reader.read_deltafailed on any table whose only extra reader feature isv2Checkpoint.After
v2Checkpointonly changes how the log is stored: a checkpoint can list the data files in sidecar files.flowchart TD subgraph Before subgraph BS[Subsystem: IO] subgraph BC[Component: read_delta reader choice] B1[Table with readerFeatures v2Checkpoint] --> B2[V2 check: unsupported feature] B2 --> B3[NotImplementedError] end end end subgraph After subgraph AS[Subsystem: IO] subgraph AC[Component: read_delta reader choice] A1[Table with readerFeatures v2Checkpoint] --> A2[V2 eligibility check: supported] A2 --> A3[DeltaFileIndexer: add actions from checkpoint + sidecars] A3 --> A4[DeltaScanner reads the files] end end end classDef removed fill:#ffcdd2,stroke:#c62828,color:#000 classDef added fill:#c8e6c9,stroke:#2e7d32,color:#000 classDef changed fill:#fff9c4,stroke:#f9a825,color:#000 class B3 removed class A2 changed class A3,A4 addedSubsystems
IO (
_internal/datasource_v2/formats/delta/delta_datasource_v2.py:_SUPPORTED_READER_FEATURES).Testing
New test.
test_reads_tables_with_v2_checkpointsreads a table whose first files are listed only in a v2 checkpoint sidecar, plus one file committed after the checkpoint. It checks that the read uses V2 and returns every row.NotImplementedErrorfor the feature, so the test fails. (V1'sto_pyarrow_datasetraisesDeltaProtocolErrorfor these tables.)Unit test. A new case in
test_check_delta_table_is_readable. With the change reverted, it raisesNotImplementedErrorinstead of passing.Checked against a Databricks-written table:
readerFeatures=["v2Checkpoint"], a v2 checkpoint with one sidecar;sum(id)and a filtered count matched Databricks, on deltalake 1.5.0 (the CI pin) and 1.6.6.delta.checkpoint.writeStatsAsJson=false). Those files are simply not skipped, and the filtered count is still correct.Commands and results (deltalake 1.5.0, pyarrow 23.0.1):
pytest python/ray/data/tests/datasource/test_delta_v2.py: 69 passedpytest python/ray/data/tests/unit/datasource_v2/ python/ray/data/tests/unit/datasource/: 1132 passed, 125 skippedpytest python/ray/data/tests/datasource/test_delta.py: 63 passed, 1 skippedpytest python/ray/data/tests/datasource/test_delta_v2.py -k v2_checkpointon deltalake 1.6.6: 1 passedv2Checkpointremoved from_SUPPORTED_READER_FEATURES: 1 failed (DeltaProtocolError)Not a duplicate. No open PR touches Delta
v2Checkpointsupport (searched open PRs for "v2Checkpoint" and "delta v2 checkpoint"). The V2 Delta reader only exists in this stack.AI assistance was used (Claude Code); every line has been reviewed by the submitter.
🤖 Generated with Claude Code