Skip to content

Revert "[Data] DataSourceV2: row-group-aware Parquet chunking" - #64541

Merged
goutamvenkat-anyscale merged 10 commits into
masterfrom
revert-64301-dsv2-chunking-1-rowgroup-chunker
Jul 16, 2026
Merged

goutamvenkat-anyscale merged 10 commits into
masterfrom
revert-64301-dsv2-chunking-1-rowgroup-chunker

Conversation

@abhishekverma-ray

Copy link
Copy Markdown
Contributor

Reverts #64301

@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 refactors the Parquet file chunking mechanism in Ray Data (DataSourceV2) to avoid reading file footers at listing time. ParquetFileChunker now estimates the number of chunks based on file size and a target chunk size, deferring the row-group mapping to the reader stage. Consequently, the parallel footer-reading pipeline in FileIndexer has been removed, and tests and documentation have been updated. Feedback on these changes suggests adding a validation check to prevent a potential ZeroDivisionError if target_chunk_size is zero or negative, and simplifying the mathematical formula used to calculate the starting row group index.

Comment on lines 180 to +185
if target_chunk_size is not None:
self._target_chunk_size = target_chunk_size
elif ctx.parquet_chunker_target_chunk_size is not None:
self._target_chunk_size = ctx.parquet_chunker_target_chunk_size
elif ctx.target_min_block_size is not None:
self._target_chunk_size = ctx.target_min_block_size
else:
self._target_chunk_size = self._FALLBACK_TARGET_CHUNK_SIZE
self._target_chunk_size = self._DEFAULT_TARGET_CHUNK_SIZE

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

If target_chunk_size is configured to 0 or a negative value (either via constructor argument or through DataContext), it will lead to a ZeroDivisionError or unexpected behavior in generate_chunk_metadatas when calculating num_chunks. We should add a validation check to ensure self._target_chunk_size is strictly positive.

Suggested change
if target_chunk_size is not None:
self._target_chunk_size = target_chunk_size
elif ctx.parquet_chunker_target_chunk_size is not None:
self._target_chunk_size = ctx.parquet_chunker_target_chunk_size
elif ctx.target_min_block_size is not None:
self._target_chunk_size = ctx.target_min_block_size
else:
self._target_chunk_size = self._FALLBACK_TARGET_CHUNK_SIZE
self._target_chunk_size = self._DEFAULT_TARGET_CHUNK_SIZE
if target_chunk_size is not None:
self._target_chunk_size = target_chunk_size
elif ctx.parquet_chunker_target_chunk_size is not None:
self._target_chunk_size = ctx.parquet_chunker_target_chunk_size
else:
self._target_chunk_size = self._DEFAULT_TARGET_CHUNK_SIZE
if self._target_chunk_size <= 0:
raise ValueError(
f"target_chunk_size must be strictly positive, got {self._target_chunk_size}"
)

Comment on lines +63 to +66
start = (
remainder * (base_row_groups_per_chunk + 1)
+ (chunk_idx - remainder) * base_row_groups_per_chunk
)

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

The calculation for start when chunk_idx >= remainder can be simplified mathematically. Since remainder * (base_row_groups_per_chunk + 1) + (chunk_idx - remainder) * base_row_groups_per_chunk simplifies to chunk_idx * base_row_groups_per_chunk + remainder, we can use the simplified formula to improve readability and maintainability.

        start = chunk_idx * base_row_groups_per_chunk + remainder

goutamvenkat-anyscale and others added 7 commits July 6, 2026 10:10
Signed-off-by: Goutam <[email protected]>

# Conflicts:
#	python/ray/data/_internal/datasource_v2/listing/file_indexer.py
Add a SupportsMetadata interface and a PushdownCountFiles logical rule so
Dataset.count() on a bare DataSourceV2 Parquet read is answered from file
footers (num_rows) instead of reading data columns. The rule rewrites
Count(ReadFiles(ListFiles)) to MapBatches(count_rows, ListFiles), rebuilding
ListFiles with a WholeFileChunker and no partitioner so each file is counted
once. Only applies when no row-reducing predicate/limit is present.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Signed-off-by: Goutam <[email protected]>
Set use_threads=True in the fallback iter_batches path so batches are decoded
concurrently.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Signed-off-by: Goutam <[email protected]>
@goutamvenkat-anyscale
goutamvenkat-anyscale marked this pull request as ready for review July 15, 2026 23:15
@goutamvenkat-anyscale
goutamvenkat-anyscale requested review from a team as code owners July 15, 2026 23:15
@goutamvenkat-anyscale goutamvenkat-anyscale added data Ray Data-related issues go add ONLY when ready to merge, run all tests labels Jul 15, 2026
@goutamvenkat-anyscale
goutamvenkat-anyscale enabled auto-merge (squash) July 15, 2026 23:31
@github-actions
github-actions Bot disabled auto-merge July 16, 2026 00:26
@goutamvenkat-anyscale
goutamvenkat-anyscale enabled auto-merge (squash) July 16, 2026 18:06
@goutamvenkat-anyscale
goutamvenkat-anyscale merged commit 1a3afc4 into master Jul 16, 2026
4 checks passed
@goutamvenkat-anyscale
goutamvenkat-anyscale deleted the revert-64301-dsv2-chunking-1-rowgroup-chunker branch July 16, 2026 18:44
AarryaSaraf added a commit to AarryaSaraf/ray that referenced this pull request Aug 1, 2026
The native chunked-read path read `chunk_metadata["row_group_start"]` /
`["row_group_end"]` — keys from the row-group-aware chunker (PR ray-project#64301) that
was reverted upstream (PR ray-project#64541). The current `ParquetFileChunker` emits a
relative `(chunk_idx, total_num_chunks)` descriptor and defers row-group
resolution to read time, so any chunked read raised `KeyError: 'row_group_start'`
(seen in the `read_large_parquet` release tests).

Resolve the descriptor with the same `_calculate_row_group_range` helper the
PyArrow reader uses, in both `_native_fragments_for_file` and
`_native_count_fragments`, so native fragments line up byte-for-byte with the
PyArrow path (identical row_hash offsets and limit slicing) and the
planner-over-estimated case (`None`) is handled. Update
`test_native_chunked_read_row_hash_parity` to build metadata with the real
schema; validated end-to-end that the chunked native read matches PyArrow.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Signed-off-by: Aarrya <[email protected]>
AarryaSaraf added a commit to AarryaSaraf/ray that referenced this pull request Aug 1, 2026
test_chunker_native_metadata_matches_pyarrow and
test_chunker_native_metadata_makes_no_pyarrow_footer_read asserted that the
ParquetFileChunker reads Parquet footers through the native crate at chunk
time — a capability from the row-group-aware chunker (PR ray-project#64301) that was
reverted upstream (PR ray-project#64541). The current chunker splits by byte size and
reads no footer during chunking, so both tests reference a dead
generate_chunk_metadatas(path, size, fs) signature and dead metadata keys.
The reader's own native footer read stays covered by
test_native_read_is_pyarrow_free.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Signed-off-by: Aarrya <[email protected]>
400Ping pushed a commit to 400Ping/ray that referenced this pull request Aug 18, 2026
…roject#64541)

Reverts ray-project#64301

---------

Signed-off-by: Goutam <[email protected]>
Co-authored-by: Goutam <[email protected]>
Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Signed-off-by: 400Ping <[email protected]>
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.

3 participants