Skip to content

[Data][Delta DSv2][7/7] Read Delta Lake tables through DataSourceV2 by default - #67679

Closed
abhishekverma-ray wants to merge 7 commits into
ray-project:masterfrom
abhishekverma-ray:datasources-v2/read-delta-v2-4-flag-flip
Closed

abhishekverma-ray wants to merge 7 commits into
ray-project:masterfrom
abhishekverma-ray:datasources-v2/read-delta-v2-4-flag-flip

Conversation

@abhishekverma-ray

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

Copy link
Copy Markdown
Contributor

Summary

Turns DataContext.use_delta_datasource_v2 on by default. Stacked on #67677 and #67678. Kept separate so it can be reverted alone.

Before

read_delta uses the V1 reader unless the flag is set.

After

read_delta uses the DataSourceV2 reader (version pinned at call time, listing in Ray tasks, log-statistics file skipping, row-group read units, generated-ID checkpointing). Tables it can't read yet still use V1. Opt out with RAY_DATA_USE_DELTA_DATASOURCE_V2=0 or DataContext.use_delta_datasource_v2 = False.

Subsystems

IO (DataContext default, read_delta docstring).

Testing

  • Delta suites — 95 passed; tests/unit/datasource_v2/ — 883 passed; test_catalog.py (catalog-vended filesystems through read_delta) — 46 passed; test_checkpoint.py — 97 passed.

AI assistance was used (Claude Code); every line has been reviewed by the submitter.

🤖 Generated with Claude Code

@abhishekverma-ray
abhishekverma-ray force-pushed the datasources-v2/read-delta-v2-4-flag-flip branch 3 times, most recently from 672c310 to 73ec13e Compare November 5, 2026 11:22
@abhishekverma-ray
abhishekverma-ray force-pushed the datasources-v2/read-delta-v2-4-flag-flip branch from 73ec13e to f8a7e5b Compare November 6, 2026 03:43
@abhishekverma-ray abhishekverma-ray changed the title [Data][Delta DSv2][4/4] Read Delta Lake tables through DataSourceV2 by default [Data][Delta DSv2][7/7] Read Delta Lake tables through DataSourceV2 by default Nov 6, 2026
@abhishekverma-ray
abhishekverma-ray force-pushed the datasources-v2/read-delta-v2-4-flag-flip branch 3 times, most recently from f1a9b6e to 35703c5 Compare November 10, 2026 05:16
@abhishekverma-ray abhishekverma-ray added data Ray Data-related issues go add ONLY when ready to merge, run all tests labels Nov 10, 2026
@abhishekverma-ray
abhishekverma-ray marked this pull request as ready for review November 10, 2026 06:24
@abhishekverma-ray
abhishekverma-ray requested review from a team as code owners November 10, 2026 06:24

@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 new DataSourceV2 implementation for Delta Lake tables (DeltaDatasourceV2), enabling read_delta to leverage the DataSourceV2 pipeline. It includes a log-based file indexer (DeltaFileIndexer), a Parquet-based scanner (DeltaScanner), and log statistics pruning (delta_file_pruning.py) to skip files based on query predicates. Additionally, support for Hive-style partitioning with null fallbacks has been added along with comprehensive unit and end-to-end tests. One piece of feedback suggests improving absolute path detection on Windows by checking for drive letters in resolve_data_file_path.

(for example for shallow clones), but the DataSourceV2 reader reads
through a filesystem rooted at the table.
"""
if posixpath.isabs(logged_path) or _has_scheme(logged_path):

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.

medium

On Windows, absolute paths can start with a drive letter (e.g., C:/path or C:\\path). Since posixpath.isabs only checks for a leading slash, and _has_scheme returns False for single-letter drive schemes, Windows absolute paths won't be detected as absolute. This can lead to confusing errors later when trying to read them as relative paths. Consider checking for Windows drive letters as well.

Suggested change
if posixpath.isabs(logged_path) or _has_scheme(logged_path):
if posixpath.isabs(logged_path) or _has_scheme(logged_path) or (len(logged_path) > 1 and logged_path[1] == ':'):

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

Stale Bugbot comment from a previous run.

@abhishekverma-ray
abhishekverma-ray force-pushed the datasources-v2/read-delta-v2-4-flag-flip branch 2 times, most recently from a1c1597 to 324dc0f Compare November 11, 2026 05:57

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

Stale Bugbot comment from a previous run.

@abhishekverma-ray
abhishekverma-ray force-pushed the datasources-v2/read-delta-v2-4-flag-flip branch 2 times, most recently from d640ed7 to 18b2be4 Compare November 16, 2026 03:09

@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 18b2be4. Configure here.

abhishekverma-ray and others added 4 commits November 16, 2026 12:26
Add the listing for the Delta Lake DataSourceV2 reader. A Delta table's
data files are the ones its transaction log names at a version, not
whatever the table directory holds, so the indexers here read the file
list from the log instead of walking directories:

- `DeltaTableSnapshot`: a picklable reference to one table version. A
  `deltalake.DeltaTable` can't be pickled, so listing tasks reopen the
  table from it at the version the driver pinned.
- `DeltaFileIndexer(_DeltaLogListing, FooterFileIndexer)`: lists the
  `add` actions, then reads each file's Parquet footer, so listing rows
  are row-group runs (pruning, read units and resume as for Parquet).
- `DeltaWholeFileIndexer`: the log-based listing for metadata-only reads.
  `FooterFileIndexer.as_whole_file_indexer` would walk the directory.
- Paths are relative to the table root and URL-decoded once. Partition
  values come from Hive-style directories, parsed with
  `null_fallback=HIVE_DEFAULT_PARTITION`; a file not under them, or a
  partition value that is literally `__HIVE_DEFAULT_PARTITION__`, fails
  the listing instead of reading wrong values.
- The indexer carries the table's filesystem and the read's shuffle,
  since the framework passes neither to a metadata-backed source.

Nothing uses the indexers yet: the datasource and `read_delta` wiring
follow in separate PRs.

Co-authored-by: tobby168 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Abhishek Verma <[email protected]>
The listing took each file's partition values from its Hive directory and
dropped the ones the log records, so it failed tables the V1 reader reads:
files outside partition directories (the Delta protocol doesn't require
them) and the string `__HIVE_DEFAULT_PARTITION__`, which shares a directory
with null values.

Now the listing reads the values from the `add` actions:
- `partition_values_as_strings` casts them to the table's types and back to
  strings with Arrow, the form the reader casts back exactly, as it does a
  value parsed from a path.
- `DeltaPartitionPruner` evaluates the pushed-down partition predicate on
  those values.
- Both indexers add them to each manifest in `PARTITION_VALUES_COLUMN`,
  which the bin packer carries to the read tasks.
  The reader that uses it comes with the datasource.

The two directory checks go. Also drop the unused
`list_files_from_file_infos` override and `DeltaWholeFileIndexer`'s
`shuffle_config`, and the unit tests that the `read_delta` tests cover.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Abhishek Verma <[email protected]>
Add `DeltaDatasourceV2`, a `DataSourceWithMetadata` for one version of a
Delta Lake table, and `DeltaScanner`:

- The driver opens the log without its file list, pins the version and
  takes the schema and partition columns from the log; listing goes
  through the `DeltaFileIndexer` from the previous PR.
- Data files are Parquet: `DeltaScanner` is a `ParquetScanner`, so the
  filter, column and limit pushdown are inherited. Partition columns keep
  their place in the output, and an `include_paths` `path` column comes
  last, as with the V1 reader.
- Partition values come from the log, not from the paths:
  `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.
  `ParquetScanner` gets a `reader_class` attribute for that.
- Everything is read through a filesystem rooted at the table directory,
  as `DeltaTable.to_pyarrow_dataset` does: the caller's, or a
  `deltalake` `DeltaStorageHandler` built from `storage_options`.
- `delta_datasource_v2_unsupported_reason` says why 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`.
- `generated_id_column` rejects Delta reads for now.
- The pickle gate scan allowlists `delta_datasource_v2.py`, whose only
  match is a schema `.to_arrow()`; data files are read and gated in
  `ParquetFileReader`.

`read_delta` doesn't use the datasource yet; that wiring follows in a
separate PR.

Co-authored-by: tobby168 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Abhishek Verma <[email protected]>
Route `read_delta` through `DeltaDatasourceV2` when the new
`DataContext.use_delta_datasource_v2` (env
`RAY_DATA_USE_DELTA_DATASOURCE_V2`, default off) and `use_datasource_v2`
are both set. The driver then opens only the log (`without_files=True`),
and tables `delta_datasource_v2_unsupported_reason` rejects keep using
the V1 reader, with an info log saying why. Reads that pass
`partition_filters` also use the V1 reader: the V2 reader doesn't apply
them yet, so it would read every partition.

Every `test_delta.py` test now runs under both readers (except the V1
listing's no-`get_file_info` check: V2 lists in Ray tasks, and
`test_delta_file_indexer.py` covers its log sizes), and
`test_delta_v2.py` checks that V2 returns the same rows and schema as V1
for partitioned tables, filters, `columns=`, `include_paths` and a
table-rooted `filesystem=`, plus count after overwrite, version pinning,
row-group read units, resume, shuffle and the V1 fallbacks. Tables
whose paths don't give their partition values (random file prefixes,
timestamp partitions with a time zone, the string
`__HIVE_DEFAULT_PARTITION__` next to nulls) read the same through V2,
with and without a filter on the partition column.

Co-authored-by: tobby168 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Abhishek Verma <[email protected]>
abhishekverma-ray and others added 3 commits November 16, 2026 12:26
The DataSourceV2 Delta reader lists every data file of the pinned
version and reads every footer. Each `add` action in the log carries the
file's per-column minimum and maximum, so a file whose range proves no
row can match the read's predicate is now left out of the listing,
before its footer is read (ray-project#61547).

Skipping is conservative: anything unprovable keeps the file, and the
reader still applies the predicate to every row. Only bounds that are
exact for their type are used: string maximums can be truncated by the
writer, timestamp statistics are stored in milliseconds, and float
bounds may be NaN. Supports comparisons with a literal on either side,
IN, AND and OR.

Co-authored-by: tobby168 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Abhishek Verma <[email protected]>
A generated ID names a row's place in its Parquet data file. Delta data
files never change, so the DataSourceV2 Delta reader, whose scanner is a
`ParquetScanner`, can produce them: a job resumed against the same table
version finds every ID again, and its listing skips the finished files
and row groups.

`read_delta` without `version=` reads the version that is latest when
the dataset is created, so a resumed job may read a newer one, and rows
a commit in between rewrote into new files (compaction, an overwrite)
get new IDs and are processed again. Binding the column warns once in
that case and asks for `version=`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Abhishek Verma <[email protected]>
Turn `DataContext.use_delta_datasource_v2` on by default, so
`read_delta` pins the table version when called, lists the data files
in Ray tasks, skips files using the log's statistics and reads row-group
read units. Tables the DataSourceV2 reader can't read yet still use the
V1 reader. Opt out with `RAY_DATA_USE_DELTA_DATASOURCE_V2=0`.

The flip is its own change so it can be reverted alone.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Abhishek Verma <[email protected]>
@abhishekverma-ray

Copy link
Copy Markdown
Contributor Author

Closing in favor of #68286. Richard asked for the remaining Delta DSv2 PRs as a GitHub stack, so they now live on branches in ray-project/ray instead of my fork. The code is the same, rebased onto current master.

The stack is https://github.com/ray-project/ray/stack/68288, and each PR now shows only its own diff. Earlier review comments stay here for reference. Please leave new comments on #68286.

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