Skip to content

[Data][Delta DSv2][11/11] Read Delta Lake tables with v2 checkpoints through DataSourceV2 - #68287

Open
abhishekverma-ray wants to merge 1 commit into
abhishek/delta-dsv2-7-flag-flipfrom
abhishek/delta-dsv2-8-v2-checkpoint
Open

abhishekverma-ray wants to merge 1 commit into
abhishek/delta-dsv2-7-flag-flipfrom
abhishek/delta-dsv2-8-v2-checkpoint

Conversation

@abhishekverma-ray

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

Copy link
Copy Markdown
Contributor

Summary

The DataSourceV2 Delta reader now accepts the v2Checkpoint reader 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

  • The V2 reader treated v2Checkpoint as unsupported and fell back to V1.
  • V1's 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.
  • So read_delta failed on any table whose only extra reader feature is v2Checkpoint.

After

  • v2Checkpoint only changes how the log is stored: a checkpoint can list the data files in sidecar files.
  • deltalake replays checkpoints and sidecars when it builds the add actions, so the V2 reader's listing already sees every file. Partition values, sizes and log statistics come from the same add actions.
  • Such tables now read with the V2 reader, including log-statistics file skipping.
  • Tables that also need other unsupported features (deletion vectors, column mapping, ...) still raise as before ([Data][Delta DSv2][9/11] Drop the V1 fallback from the Delta DataSourceV2 reader #68408).
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 added
Loading

Subsystems

IO (_internal/datasource_v2/formats/delta/delta_datasource_v2.py: _SUPPORTED_READER_FEATURES).

Testing

New test. test_reads_tables_with_v2_checkpoints reads 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.

  • delta-rs can't write v2 checkpoints, so the test makes one from a delta-rs table: it turns the classic checkpoint into a v2 checkpoint (a top-level JSON file plus a Parquet sidecar) and deletes the commits it covers.
  • With the change reverted, the V2 check raises NotImplementedError for the feature, so the test fails. (V1's to_pyarrow_dataset raises DeltaProtocolError for these tables.)

Unit test. A new case in test_check_delta_table_is_readable. With the change reverted, it raises NotImplementedError instead of passing.

Checked against a Databricks-written table:

  • reader 3, readerFeatures=["v2Checkpoint"], a v2 checkpoint with one sidecar;
  • read through Unity Catalog credential vending, then again from a local copy with the checkpointed commits deleted;
  • V2 count, sum(id) and a filtered count matched Databricks, on deltalake 1.5.0 (the CI pin) and 1.6.6.
  • deltalake 1.5.0 doesn't return log statistics for files listed in a struct-only sidecar (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 passed
  • pytest python/ray/data/tests/unit/datasource_v2/ python/ray/data/tests/unit/datasource/: 1132 passed, 125 skipped
  • pytest python/ray/data/tests/datasource/test_delta.py: 63 passed, 1 skipped
  • pytest python/ray/data/tests/datasource/test_delta_v2.py -k v2_checkpoint on deltalake 1.6.6: 1 passed
  • The same test with v2Checkpoint removed from _SUPPORTED_READER_FEATURES: 1 failed (DeltaProtocolError)
  • pre-commit and pyrefly (CI settings) on the changed files: clean

Not a duplicate. No open PR touches Delta v2Checkpoint support (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

@gemini-code-assist

Copy link
Copy Markdown
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
abhishekverma-ray marked this pull request as ready for review November 18, 2026 03:20
@abhishekverma-ray
abhishekverma-ray requested review from a team as code owners November 18, 2026 03:20
@gemini-code-assist

Copy link
Copy Markdown
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 abhishekverma-ray added data Ray Data-related issues go add ONLY when ready to merge, run all tests labels Nov 18, 2026
@abhishekverma-ray
abhishekverma-ray force-pushed the abhishek/delta-dsv2-8-v2-checkpoint branch from 246c47a to dddb539 Compare November 18, 2026 04:36
@abhishekverma-ray
abhishekverma-ray force-pushed the abhishek/delta-dsv2-8-v2-checkpoint branch from dddb539 to 6350227 Compare November 19, 2026 03:48
@abhishekverma-ray
abhishekverma-ray force-pushed the abhishek/delta-dsv2-8-v2-checkpoint branch from 6350227 to 9fed2b3 Compare November 19, 2026 04:23
@abhishekverma-ray
abhishekverma-ray removed this pull request from stack #68288 November 19, 2026 04:25
@abhishekverma-ray abhishekverma-ray changed the title [Data][Delta DSv2][8/8] Read Delta Lake tables with v2 checkpoints through DataSourceV2 [Data][Delta DSv2][9/9] Read Delta Lake tables with v2 checkpoints through DataSourceV2 Nov 19, 2026
@abhishekverma-ray
abhishekverma-ray force-pushed the abhishek/delta-dsv2-8-v2-checkpoint branch from 9fed2b3 to c288bac Compare November 19, 2026 04:49
@abhishekverma-ray
abhishekverma-ray force-pushed the abhishek/delta-dsv2-8-v2-checkpoint branch from c288bac to 6d0e9e0 Compare November 20, 2026 17:28
@abhishekverma-ray
abhishekverma-ray removed this pull request from stack #68331 November 20, 2026 17:29
@abhishekverma-ray abhishekverma-ray changed the title [Data][Delta DSv2][9/9] Read Delta Lake tables with v2 checkpoints through DataSourceV2 [Data][Delta DSv2][11/11] Read Delta Lake tables with v2 checkpoints through DataSourceV2 Nov 20, 2026
@abhishekverma-ray
abhishekverma-ray force-pushed the abhishek/delta-dsv2-8-v2-checkpoint branch 2 times, most recently from 192ca54 to 5800871 Compare November 23, 2026 10:26
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
sampan-s-nayak force-pushed the abhishek/delta-dsv2-8-v2-checkpoint branch from 5800871 to dc3f33a Compare November 23, 2026 11:13
@abhishekverma-ray
abhishekverma-ray force-pushed the abhishek/delta-dsv2-8-v2-checkpoint branch from dc3f33a to 9c67a74 Compare November 23, 2026 14:41
@abhishekverma-ray
abhishekverma-ray force-pushed the abhishek/delta-dsv2-8-v2-checkpoint branch from 9c67a74 to 9426f80 Compare November 24, 2026 03:09
@abhishekverma-ray
abhishekverma-ray force-pushed the abhishek/delta-dsv2-8-v2-checkpoint branch from 9426f80 to 06914fc Compare November 24, 2026 05:57
@abhishekverma-ray
abhishekverma-ray force-pushed the abhishek/delta-dsv2-8-v2-checkpoint branch from 06914fc to c7b77b6 Compare November 25, 2026 02:54
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
abhishekverma-ray force-pushed the abhishek/delta-dsv2-8-v2-checkpoint branch from c7b77b6 to df99b8d Compare November 26, 2026 03:34

This branch has not been deployed

No deployments
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.

1 participant