You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit a03167a
Browse filesBrowse the repository at this point in the historyBrowse files
committed
[Data] Read Delta Lake tables through DataSourceV2 behind a flag
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]>
Copy file name to clipboardExpand all lines: python/ray/data/_internal/datasource_v2/README.md
+9Lines changed: 9 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,7 @@ The read path behind `ray.data.read_*` when
5
5
and *how* to decode it; the framework does listing, planning, pushdown, task
6
6
grouping and execution. Parquet is the file-based reference implementation.
7
7
Hive uses the metadata-backed path to stream one HiveServer2 query per execution.
8
+
Delta Lake uses it to list the data files a table version's log names.
8
9
9
10
## Layout
10
11
@@ -160,3 +161,11 @@ Every hook's docstring says when to override it and what you gain.
160
161
`infer_schema(None)` resolves the table schema on the driver through HiveServer2 (HS2) metadata, or returns the explicit Arrow schema for a query. `_HiveScanner.read_schema()` reports that schema. The scanner carries the read specification, including a connection factory that Ray can serialize, and schema to the worker, where it creates a `_HiveReader`. The factory creates separate connections for driver metadata lookup and worker data reads. The reader executes at most one HS2 data query and uses `fetchmany()` to yield Arrow tables incrementally.
161
162
162
163
Once the data connection is open, `read_hs2_batches()` attempts to cancel the operation and close any cursor and the connection in `finally`. This covers completion, errors, and early generator closure. Cleanup is best effort. Closing a Dataset iterator can force the streaming executor to stop the read worker while it's fetching rows. That forced stop can bypass the reader's `finally`, even when the caller closes the iterator normally. Abrupt worker termination can also prevent `finally` from running, so immediate server cancellation or explicit cursor and connection cleanup isn't guaranteed.
164
+
165
+
## How does Delta Lake fit?
166
+
167
+
`DeltaDatasourceV2` extends `DataSourceWithMetadata`, because a Delta table's data files are the ones its transaction log names at a version, not whatever the table directory holds. `read_delta` uses it when `use_datasource_v2` and `use_delta_datasource_v2` are both set and `delta_datasource_v2_unsupported_reason()` finds nothing the V1 reader would handle differently (deletion vectors, column mapping, PyArrow scan options, ...).
168
+
169
+
On the driver, `read_delta` opens the log without its file list, pins the version and takes the schema and partition columns from the log. `DeltaFileIndexer` gets a picklable `DeltaTableSnapshot`, reopens the table at that version in the `ListFiles` task and lists the `add` actions. It extends `FooterFileIndexer`, which reads each file's footer, so listing rows are row-group runs and `OnlineBinPacker` groups them as for Parquet; `as_whole_file_indexer()` returns a log-based `DeltaWholeFileIndexer` for metadata-only reads.
170
+
171
+
The data files are Parquet: `DeltaScanner` is a `ParquetScanner`. Partition values come from the `add` actions, not from the paths: the Delta protocol doesn't require partition directories, and a null and the string `__HIVE_DEFAULT_PARTITION__` share one. The listing prunes files on those values (`DeltaPartitionPruner`) and puts them in each manifest's `__delta_partition_values` column, which `OnlineBinPacker` carries to `DeltaFileReader`. Everything is read through a filesystem rooted at the table directory with paths relative to it, as `DeltaTable.to_pyarrow_dataset` does: the `filesystem` argument, or the one `deltalake` builds from `storage_options`.
0 commit comments