Repository navigation
Revert "[Data] DataSourceV2: row-group-aware Parquet chunking" - #64541
goutamvenkat-anyscale merged 10 commits into
Conversation
This reverts commit 6627f78.
There was a problem hiding this comment.
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.
| 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 |
There was a problem hiding this comment.
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.
| 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}" | |
| ) |
| start = ( | ||
| remainder * (base_row_groups_per_chunk + 1) | ||
| + (chunk_idx - remainder) * base_row_groups_per_chunk | ||
| ) |
There was a problem hiding this comment.
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 + remainderSigned-off-by: Goutam <[email protected]>
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]>
Signed-off-by: Goutam <[email protected]>
Signed-off-by: Goutam <[email protected]>
Signed-off-by: Goutam <[email protected]>
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]>
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]>
…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]>
Reverts #64301