Repository navigation
[Data] [1/4] Add generated_id_column to CheckpointConfig with V2 Parquet row-group IDs - #65885
Conversation
…w-group IDs Ports step 1-2 of RayTurbo's row-group checkpointing: a CheckpointConfig generated_id_column that synthesizes a stable struct ID per row (path_prefix/file_name/fragment/num_fragments/num_rows/row_id) on the datasource_v2 Parquet read path. - CheckpointConfig: generated_id_column XOR id_column; the generated name aliases id_column so the existing write 2PC keys off it unchanged. - ParquetFileReader fans one sub-fragment per row group and attaches IDs per batch; row_id continues across batches within a row group; raises on collision with an existing on-disk column. - Schema advertised consistently on ParquetScanner.read_schema() and ParquetDatasourceV2.infer_schema(); ID survives column projection and is stripped from the pyarrow dataset schema. Until the follow-up commits (compact checkpoint load, list/read-time skip, planner routing), the column only generates IDs; nothing is skipped on resume yet. Signed-off-by: Abhishek Verma <[email protected]>
There was a problem hiding this comment.
Code Review
This pull request introduces support for auto-generated row IDs during checkpointing, specifically for Parquet-based data sources, when an explicit ID column is not present in the input dataset. It adds a generated_id_column configuration to CheckpointConfig, updates the V2 Parquet reader to synthesize stable (file, row group, row) identifiers, and includes corresponding unit tests. The review feedback highlights an opportunity to optimize the construction of dictionary-encoded constant columns in generated_id.py by directly creating a pa.DictionaryArray with repeated indices to avoid unnecessary memory allocation and CPU overhead.
…direct dictionary construction Two review-bot findings on the PR: - Cursor Bugbot (high): with generated_id_column aliased onto id_column, the planner's existing wiring planned the numpy-based checkpoint filter, so a rerun that found committed struct-ID checkpoint files crashed in convert_and_sort_checkpointed_ids instead of re-reading. The planner now plans only the Write 2PC for generated-ID configs: checkpoints are written, and a rerun re-reads every row (at-least-once). Restore routing for generated IDs arrives with the ListFiles-based row-group skip. Regression test reproduces the crash without the gate. - Gemini (medium): constant struct fields were built via nulls -> fill_null -> dictionary_encode per batch; construct the DictionaryArray directly from a one-element dictionary and repeated zero indices. Struct type is unchanged (covered by existing tests). Signed-off-by: Abhishek Verma <[email protected]>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Reviewed by Cursor Bugbot for commit 365537c. Configure here.
Pending-checkpoint cleanup doesn't depend on the ID type, but it lives inside the checkpoint-load path that generated-ID configs skip (only the write-side 2PC is planned). Run it at plan time instead, so a retry after a mid-write crash still deletes leftover pending checkpoints and their partially written data files before writing again. Regression test simulates the crashed run's leftovers. Signed-off-by: Abhishek Verma <[email protected]>
|
What is the difference between the "generated_id_column" vs the existing one from "include_row_hash=True"? it seems that the existing one didn't care about the row groups. Does data source v2 use "split_by_row_group()" now? I guess it may be simpler to extend/generalize the current "row_hash". What do you think |
| checkpoint_config.checkpoint_manager_cls or IdColumnCheckpointManager | ||
| ) | ||
| manager = manager_cls(checkpoint_config, data_context) | ||
| manager._clean_pending_checkpoints(data_file_dir, data_file_filesystem) |
There was a problem hiding this comment.
What is the point of this change in the planner? I see that it gets nuked in 4/4 PR
There was a problem hiding this comment.
It's deliberate, so this PR is safe to merge standalone.
Without this change, the existing planner wiring treats the generated column like a normal id_column (it's aliased onto config.id_column), so a rerun that finds committed checkpoints crashes in convert_and_sort_checkpointed_ids — struct IDs can't go through the numpy sort/searchsorted path (Bugbot caught this above).
The interim semantics in this PR are: checkpoints are written via the shared 2PC, pending leftovers from a crashed run are cleaned at plan time, and a rerun re-reads everything (at-least-once, no crash).
4/4 then replaces this with the real ListFiles-based restore routing, where cleanup happens inside the compact checkpoint load — which is why the plan-time version goes away there.
Good question.
|
The module-level helper had no production callers (the planner uses CheckpointConfig.has_generated_id_column directly) and, as an unannotated public symbol, failed CI's API-annotation check. Delete it and assert the property directly in tests. Co-Authored-By: Claude Fable 5 <[email protected]> Signed-off-by: Abhishek Verma <[email protected]>
…th V2 Parquet row-group IDs" (#66183) Reverts #65885 Reverting this PR to clean up DSv2 first. Signed-off-by: Aarrya <[email protected]> Co-authored-by: Claude Fable 5.1 <[email protected]>
…sh flags with SynthesizedColumn objects (#66390) ## Description `include_paths=True` adds a `path` column to every row and `include_row_hash=True` adds `row_hash`. Each is a boolean threaded through `ParquetDatasourceV2` → `ParquetScanner` → `ParquetFileReader` → `FileReader`, and each boolean drives the same steps written out by hand: advertise the column in the schema, keep pyarrow from looking for it in the file, skip it when a projection dropped it, build it per batch, and (for `row_hash`) scan one row group at a time so the value can depend on the row's position. The checkpointing work (#65885, reverted; #65887) needs a third such column and added a third boolean plus a 130-line copy of the read loop. This PR replaces the booleans with `SynthesizedColumn` objects. The reader does the steps once for whatever columns it is given; a new column is a small class and touches no reader code. ### What changes 1. **`readers/synthesized_columns.py` (new).** `SynthesizedColumn` with `name`, `type`, `requires_read_unit_boundaries` and `compute(position, num_rows)`; `ReadUnitPosition` (the read unit a table of rows came from plus its row offsets); `PathColumn` and `RowHashColumn`. `_compute_row_hashes` and the two column-name constants move here from `file_reader.py`, which re-exports them for the legacy datasource. 2. **`read_units.py` (new).** `ReadUnit`: the piece of a file a reader scans on its own, a row group or a whole file, with a stable id (`<path>#rg<i>`), its index, the file's group count and its row count. This is what a checkpoint ID column needs to name a row. 3. **`parquet_datasource_v2.py`.** The two flags become a tuple of column objects; `infer_schema` appends each column's name and type in one loop. The unused `include_paths` property is gone. 4. **`scanners/parquet_scanner.py`.** One `synthesized_columns` field replaces the two booleans; `read_schema` loops over it with the same skip rules. 5. **`readers/file_reader.py`.** Constructor takes the tuple. The pyarrow schema strips the configured column names. `_get_fragments_to_read` returns `(fragment, ReadUnit, file_row_offset)` and the read loop yields `(table, ReadUnitPosition)`. The `row_hash` block becomes a loop over the columns; the `path` line leaves the partition block because `PathColumn` goes through the same loop. 6. **`readers/parquet_file_reader.py`** and **`chunkers/parquet_file_chunking_utils.py`.** Per-row-group fan-out is keyed on "any column requires boundaries" instead of `include_row_hash`, and each sub-fragment comes back with its `ReadUnit`. Same footer read, same condition. 7. **Tests.** `tests/unit/datasource_v2/test_synthesized_columns.py` (new): fan-out is one unit per file unless a column needs boundaries, a whole-file manifest row stays one unit, `row_hash` is identical whole-file vs per-row-group, a same-named file column is replaced, `read_schema` respects projection. Three asserts in `test_parquet_datasource_v2.py` updated. ### Before / after: adding a column Before, #65885 added `generated_id_column` as a third boolean: +160 lines across four `datasource_v2` files, 129 of them a `ParquetFileReader` override duplicating `_read_fragments_sequential`. After, the same column is one class next to `RowHashColumn` and no reader change: ```python class CheckpointIdColumn(SynthesizedColumn): name = ...; type = GENERATED_ID_COLUMN_TYPE requires_read_unit_boundaries = True def compute(self, position, num_rows): u = position.unit return get_generated_id_column(u.source, u.index, u.count, u.num_rows, position.unit_row_offset, num_rows) ``` ### Behavior Row order, appended-column order (partitions, `path`, `row_hash`), the row-hash arithmetic, retry scoping and the fan-out condition are unchanged. One intended fix: for a file that already has a non-string column named `path`, read with `include_paths=True`, `ds.schema()` now says `path: string`, which is what the blocks always carried. Related to that, the schema handed to pyarrow strips `path` only when `PathColumn` is configured, where it used to strip it unconditionally. ## Additional information Not a duplicate: no open PR introduces column objects or read units. #65887 (checkpoint skipping) edits the same reader files with its own booleans; this PR is the seam that work can move onto. #65989 (mine) is about predicates naming a synthesized column and is independent. Checks run locally from this branch (macOS, `~/ray/.venv`): ``` pytest -q tests/unit/datasource_v2 # 133 passed ``` `ruff`, `black` and `pydoclint` at the pre-commit pins are clean; `pyrefly` via `ci/lint/pyrefly-check.sh` reports 59 errors against 61 on the base, none new. Written with Claude Code; I reviewed every changed line and ran the tests above. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Signed-off-by: Aarrya <[email protected]> Co-authored-by: Claude Fable 5.1 <[email protected]>
…rquet row-group IDs (ray-project#65885) **Stack:** PR 1 of 4 porting row-group–based job-level checkpointing to the V2 datasource path. This PR is standalone; follow-ups: [2/4] compact checkpoint load, [3/4] list/read-time skipping, [4/4] planner routing + docs. ## Why are these changes needed? Job-level checkpointing (`CheckpointConfig`) currently requires the dataset to carry a unique `id_column`. Many batch-inference datasets have no natural ID. This PR adds `CheckpointConfig(generated_id_column=...)`: for Parquet sources on the V2 datasource path, the reader synthesizes a stable struct ID per row derived from the physical file layout — `{path_prefix, file_name, fragment (= row group index), num_fragments, num_rows, row_id}` (dictionary-encoded; `row_id` is the position within the row group). In this PR the column only gets generated and written through the existing checkpoint 2PC (the generated name is aliased onto `CheckpointConfig.id_column`, so the write path is untouched). Skipping committed work on resume lands in the follow-up PRs; until then, enabling `generated_id_column` produces IDs but a rerun re-reads everything. Key pieces: - `python/ray/data/checkpoint/generated_id.py` (new): ID struct type and construction. - `CheckpointConfig`: `generated_id_column` XOR `id_column` validation; aliasing so downstream code keys off `id_column` unchanged. - `ParquetFileReader`: fans out one sub-fragment per row group when the feature is on (the invariant the ID derivation relies on) and attaches the ID per batch; `row_id` continues across batches within a row group; raises on collision with an existing on-disk column. - Schema consistency: the ID column is advertised on both `ParquetScanner.read_schema()` (what `ds.schema()` shows) and `ParquetDatasourceV2.infer_schema()` (what plan construction uses), survives column projection, and is stripped from the pyarrow dataset schema (it's synthesized, not on disk). Design note (deliberate, matches the reference implementation): under a pushed-down predicate, `row_id` indexes the *filtered* stream, not on-disk positions. ID assignment is deterministic for an unchanged pipeline, which is the standing correctness assumption for checkpoint resume; the ID's `num_rows` field still reports the on-disk row-group size, so a predicate-filtered row group can never be considered fully checkpointed. Pinned by `test_filter_pushdown_positions_are_deterministic`. ## Related issue number N/A. Not a duplicate: searched open PRs/issues in ray-project/ray for `generated_id_column`, "row group checkpoint", "checkpoint generated id" — no overlapping work. ## Checks - [x] I've signed off every commit (DCO). - [x] I've run pre-commit hooks (`pre-commit run` on all touched files — clean). - [x] AI assistance (Claude Code) was used for the development of this PR. I, Abhishek Verma, am the human submitter signing off on it: I have reviewed every changed line, run the tests below locally, and can defend the change end-to-end. - Testing: - New unit tests: `python/ray/data/_internal/datasource_v2/tests/test_generated_id_reads.py` (ID uniqueness across files/row groups, `row_id` continuation across batches, collision rejection, projection survival, `infer_schema` advertisement, filter-pushdown determinism, no-op without config) — `pytest ... -q` → 7 passed. - Config tests in `python/ray/data/tests/test_checkpoint.py::TestCheckpointConfig` (XOR/neither-set errors, aliasing) — 27 passed. - Regression: full `test_checkpoint.py` (97/98 locally; the one failure is `test_skip_checkpoint_flag[s3]`, a pre-existing local moto-server slowness that also fails on clean master), `_internal/datasource_v2/tests/` (99 passed), `tests/test_parquet.py` (passed). --------- Signed-off-by: Abhishek Verma <[email protected]> Co-authored-by: Claude Fable 5 <[email protected]>
…th V2 Parquet row-group IDs" (ray-project#66183) Reverts ray-project#65885 Reverting this PR to clean up DSv2 first. Signed-off-by: Aarrya <[email protected]> Co-authored-by: Claude Fable 5.1 <[email protected]>
…sh flags with SynthesizedColumn objects (ray-project#66390) ## Description `include_paths=True` adds a `path` column to every row and `include_row_hash=True` adds `row_hash`. Each is a boolean threaded through `ParquetDatasourceV2` → `ParquetScanner` → `ParquetFileReader` → `FileReader`, and each boolean drives the same steps written out by hand: advertise the column in the schema, keep pyarrow from looking for it in the file, skip it when a projection dropped it, build it per batch, and (for `row_hash`) scan one row group at a time so the value can depend on the row's position. The checkpointing work (ray-project#65885, reverted; ray-project#65887) needs a third such column and added a third boolean plus a 130-line copy of the read loop. This PR replaces the booleans with `SynthesizedColumn` objects. The reader does the steps once for whatever columns it is given; a new column is a small class and touches no reader code. ### What changes 1. **`readers/synthesized_columns.py` (new).** `SynthesizedColumn` with `name`, `type`, `requires_read_unit_boundaries` and `compute(position, num_rows)`; `ReadUnitPosition` (the read unit a table of rows came from plus its row offsets); `PathColumn` and `RowHashColumn`. `_compute_row_hashes` and the two column-name constants move here from `file_reader.py`, which re-exports them for the legacy datasource. 2. **`read_units.py` (new).** `ReadUnit`: the piece of a file a reader scans on its own, a row group or a whole file, with a stable id (`<path>#rg<i>`), its index, the file's group count and its row count. This is what a checkpoint ID column needs to name a row. 3. **`parquet_datasource_v2.py`.** The two flags become a tuple of column objects; `infer_schema` appends each column's name and type in one loop. The unused `include_paths` property is gone. 4. **`scanners/parquet_scanner.py`.** One `synthesized_columns` field replaces the two booleans; `read_schema` loops over it with the same skip rules. 5. **`readers/file_reader.py`.** Constructor takes the tuple. The pyarrow schema strips the configured column names. `_get_fragments_to_read` returns `(fragment, ReadUnit, file_row_offset)` and the read loop yields `(table, ReadUnitPosition)`. The `row_hash` block becomes a loop over the columns; the `path` line leaves the partition block because `PathColumn` goes through the same loop. 6. **`readers/parquet_file_reader.py`** and **`chunkers/parquet_file_chunking_utils.py`.** Per-row-group fan-out is keyed on "any column requires boundaries" instead of `include_row_hash`, and each sub-fragment comes back with its `ReadUnit`. Same footer read, same condition. 7. **Tests.** `tests/unit/datasource_v2/test_synthesized_columns.py` (new): fan-out is one unit per file unless a column needs boundaries, a whole-file manifest row stays one unit, `row_hash` is identical whole-file vs per-row-group, a same-named file column is replaced, `read_schema` respects projection. Three asserts in `test_parquet_datasource_v2.py` updated. ### Before / after: adding a column Before, ray-project#65885 added `generated_id_column` as a third boolean: +160 lines across four `datasource_v2` files, 129 of them a `ParquetFileReader` override duplicating `_read_fragments_sequential`. After, the same column is one class next to `RowHashColumn` and no reader change: ```python class CheckpointIdColumn(SynthesizedColumn): name = ...; type = GENERATED_ID_COLUMN_TYPE requires_read_unit_boundaries = True def compute(self, position, num_rows): u = position.unit return get_generated_id_column(u.source, u.index, u.count, u.num_rows, position.unit_row_offset, num_rows) ``` ### Behavior Row order, appended-column order (partitions, `path`, `row_hash`), the row-hash arithmetic, retry scoping and the fan-out condition are unchanged. One intended fix: for a file that already has a non-string column named `path`, read with `include_paths=True`, `ds.schema()` now says `path: string`, which is what the blocks always carried. Related to that, the schema handed to pyarrow strips `path` only when `PathColumn` is configured, where it used to strip it unconditionally. ## Additional information Not a duplicate: no open PR introduces column objects or read units. ray-project#65887 (checkpoint skipping) edits the same reader files with its own booleans; this PR is the seam that work can move onto. ray-project#65989 (mine) is about predicates naming a synthesized column and is independent. Checks run locally from this branch (macOS, `~/ray/.venv`): ``` pytest -q tests/unit/datasource_v2 # 133 passed ``` `ruff`, `black` and `pydoclint` at the pre-commit pins are clean; `pyrefly` via `ci/lint/pyrefly-check.sh` reports 59 errors against 61 on the base, none new. Written with Claude Code; I reviewed every changed line and ran the tests above. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Signed-off-by: Aarrya <[email protected]> Co-authored-by: Claude Fable 5.1 <[email protected]>
…as a DSv2 synthesized column (#66732) ## Why are these changes needed? Job-level checkpointing (`CheckpointConfig(id_column=...)`) needs a unique ID column in the input. Many batch-inference datasets don't have one. Ray Data generates a stable ID for every row from where it lives in its Parquet file, and a resumed job skips committed work at the source. This is a redo of #65885, which was reverted (#66183) so the DSv2 reorg could land first. The reorg added the seams this needs (`SynthesizedColumn`, `ReadUnit`, the `excluded_read_unit_ids` listing hook), so this version adds **no reader code** for the ID itself. This PR (1/4) adds the config and the ID column. Restore comes in 3/4. ## What changes - **`CheckpointConfig(generated_id_column=...)`**, exactly one of `id_column` / `generated_id_column`. The generated name is also exposed as `id_column`, so the existing checkpoint write (two-phase commit) works unchanged. - **`GeneratedIdColumn`** (`checkpoint/generated_id.py`), a `SynthesizedColumn` with `requires_read_unit_boundaries = True`. It builds a struct ID per row from the batch's `ReadUnitPosition`: `path_prefix`, `file_name`, `fragment` (row group), `num_fragments`, `num_rows`, `row_id` (position in the row group). - **Whole-file guard:** if a batch comes from a whole-file read unit (no row-group info), the column raises instead of writing IDs that can't name a row group. Parquet always lists by footer today, so this isn't reachable in normal reads. - **Explicit plumbing, no public API change:** `read_parquet` builds the column from the checkpoint config and passes it to `ParquetDatasourceV2(extra_synthesized_columns=...)`. Ray Data's own checkpoint reads opt out with an internal `_add_generated_id_column=False`, popped from `**arrow_parquet_args` like the existing `_block_udf`. Checkpoint files are Parquet too and must never get the column. - **Name clash:** `ParquetDatasourceV2.infer_schema` raises if a file already has a column with the requested name, instead of silently replacing user data the way `path` / `row_hash` do. - **Safe on its own:** until 3/4 wires up restore, the planner plans only the checkpoint write for generated-ID configs (plus cleanup of a crashed run's pending checkpoints). A rerun redoes every row instead of sending struct IDs into the numpy-based `id_column` filter. ## Related issue number N/A. Not a duplicate: I searched open PRs for `generated_id_column`, "row group checkpoint", `excluded_rows` and `requires_read_unit_boundaries`. The only matches are my earlier pre-reorg drafts #65886–#65888, which this stack replaces and which I'm closing. **Stack:** 1/4 (this, #66732) → 2/4 (#66733) → 3/4 (#66736) is the feature chain. 4/4 (#66734) is an independent speed-up that lands last. ## Checks - [x] I've signed off every commit (DCO). - [x] I've run pre-commit (`ruff`, `black`, `pydoclint`, Ray import/doc style) on all changed files: clean. The API-annotation check (`ci/lint/check_api_annotations.py`, scoped to `ray.data`) reports nothing unannotated. - [x] AI assistance (Claude Code) was used for the development of this PR. I, Abhishek Verma, am the human submitter signing off on it: I have reviewed every changed line, run the tests below locally, and can defend the change end-to-end. - Testing (macOS, nightly wheel + this branch's `ray/data`): - `pytest python/ray/data/tests/unit/datasource_v2/test_generated_id_column.py`: 10 passed. Covers ID fields per row group, uniqueness across files and row groups, `row_id` continuing across batches, determinism under a pushed-down filter, whole-file guard, projection, schema advertisement, name clash, and no-op without config. - `pytest python/ray/data/tests/test_checkpoint.py` (run from `python/ray/data/tests/`): 88 passed, 1 failed. The failure, `test_skip_checkpoint_flag[s3]`, is a pre-existing local moto-S3 timing flake that also fails on unmodified master. New tests: config validation, `read_parquet` adds the column and the checkpoint read opts out, rerun redoes rows with no filter op planned, pending-checkpoint cleanup before rerun (verified it fails without the fix). - `pytest python/ray/data/tests/unit/datasource_v2 python/ray/data/tests/datasource_v2`: 214 passed. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Signed-off-by: Abhishek Verma <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
…mark (#66680) > Stacked on #66562 (and #66563). Only review the last commit: "[Train] Add mid-epoch resumption release test". ## Description Adds a nightly release test for mid-epoch resumption with data iterator checkpointing: `mid_epoch_resume_benchmark_{10M,3B}`. `release/train_tests/mid_epoch_resume_benchmark/microbenchmark.py` runs a `TorchTrainer` with 16 mock-GPU workers over a Parquet dataset of 10M or 3B rows, using `DataConfig(dataset_checkpoint_configs={"train": DatasetCheckpointConfig(id_column="id", ...)})`. - It saves a data checkpoint with `DataIterator.state_dict()` every `checkpoint_interval` batches and at the end of each epoch, and stores it in the Ray Train checkpoint. - It injects a failure 90% of the way through the epoch (`--error_at=0.9`) and resumes from the latest checkpoint with `ray.train.get_dataset_shard("train", state_dict=...)`. - **Correctness:** after training, it checks that each epoch's checkpoint files cover exactly `total_dataset_rows` rows, so every row is seen exactly once per epoch, even across the restart. - **Performance:** it reports the total duration and the time to first batch with and without a data checkpoint, which includes the checkpoint load time. Release test config: - One test entry with a `scale` matrix (`10M`, `3B`), nightly, `byod: gpu`, `anyscale_sdk_2026: true`, and a 2700s timeout. - Compute configs (`compute_configs/{10M,3B}.yaml`): an `m5.2xlarge` head node with no CPUs, plus 10 or 50 `m5.8xlarge` workers with `MOCK_GPU: 4` and a 64 GB object store. - `--generate_id_column` is supported by the script but not passed, since `DatasetCheckpointConfig(generate_id_column=True)` isn't implemented yet (it depends on #65885–#65888). ## Related issues Not a duplicate: there's no existing release test for data iterator checkpointing or mid-epoch resumption. Generated ID column support (and `--generate_id_column` in this release test) is stacked on this PR: #66800 ## Additional information Testing: - `pre-commit run` on the changed files: passed. - The release test itself hasn't been run yet. I'll trigger it before marking this ready. AI assistance (Claude Code) was used to develop this change. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Signed-off-by: Justin Yu <[email protected]>

Stack: PR 1 of 4 porting row-group–based job-level checkpointing to the V2 datasource path. This PR is standalone; follow-ups: [2/4] compact checkpoint load, [3/4] list/read-time skipping, [4/4] planner routing + docs.
Why are these changes needed?
Job-level checkpointing (
CheckpointConfig) currently requires the dataset to carry a uniqueid_column. Many batch-inference datasets have no natural ID. This PR addsCheckpointConfig(generated_id_column=...): for Parquet sources on the V2 datasource path, the reader synthesizes a stable struct ID per row derived from the physical file layout —{path_prefix, file_name, fragment (= row group index), num_fragments, num_rows, row_id}(dictionary-encoded;row_idis the position within the row group).In this PR the column only gets generated and written through the existing checkpoint 2PC (the generated name is aliased onto
CheckpointConfig.id_column, so the write path is untouched). Skipping committed work on resume lands in the follow-up PRs; until then, enablinggenerated_id_columnproduces IDs but a rerun re-reads everything.Key pieces:
python/ray/data/checkpoint/generated_id.py(new): ID struct type and construction.CheckpointConfig:generated_id_columnXORid_columnvalidation; aliasing so downstream code keys offid_columnunchanged.ParquetFileReader: fans out one sub-fragment per row group when the feature is on (the invariant the ID derivation relies on) and attaches the ID per batch;row_idcontinues across batches within a row group; raises on collision with an existing on-disk column.ParquetScanner.read_schema()(whatds.schema()shows) andParquetDatasourceV2.infer_schema()(what plan construction uses), survives column projection, and is stripped from the pyarrow dataset schema (it's synthesized, not on disk).Design note (deliberate, matches the reference implementation): under a pushed-down predicate,
row_idindexes the filtered stream, not on-disk positions. ID assignment is deterministic for an unchanged pipeline, which is the standing correctness assumption for checkpoint resume; the ID'snum_rowsfield still reports the on-disk row-group size, so a predicate-filtered row group can never be considered fully checkpointed. Pinned bytest_filter_pushdown_positions_are_deterministic.Related issue number
N/A. Not a duplicate: searched open PRs/issues in ray-project/ray for
generated_id_column, "row group checkpoint", "checkpoint generated id" — no overlapping work.Checks
pre-commit runon all touched files — clean).python/ray/data/_internal/datasource_v2/tests/test_generated_id_reads.py(ID uniqueness across files/row groups,row_idcontinuation across batches, collision rejection, projection survival,infer_schemaadvertisement, filter-pushdown determinism, no-op without config) —pytest ... -q→ 7 passed.python/ray/data/tests/test_checkpoint.py::TestCheckpointConfig(XOR/neither-set errors, aliasing) — 27 passed.test_checkpoint.py(97/98 locally; the one failure istest_skip_checkpoint_flag[s3], a pre-existing local moto-server slowness that also fails on clean master),_internal/datasource_v2/tests/(99 passed),tests/test_parquet.py(passed).