-
Notifications
You must be signed in to change notification settings - Fork 7k
[Data] - Grab schema from 1st bundle and defer execution of write #59271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Data] - Grab schema from 1st bundle and defer execution of write #59271
Conversation
Signed-off-by: Goutam <[email protected]>
There was a problem hiding this comment.
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 write datasink logic to defer on_write_start until the first data bundle is available, allowing schema-dependent initialization. This is a significant and useful change. My review focuses on the correctness of this new deferred execution flow and related refactorings.
I've found a critical issue in dataset.py where a refactoring of the Schema.types method has removed a necessary check, which will cause failures for Arrow-backed datasets. I've also pointed out a minor code cleanup opportunity by removing some redundant imports.
Overall, the changes are well-structured, but the identified critical issue should be addressed before merging.
Signed-off-by: Goutam <[email protected]>
Signed-off-by: Goutam <[email protected]>
Signed-off-by: Goutam <[email protected]>
python/ray/data/_internal/execution/operators/actor_pool_map_operator.py
Show resolved
Hide resolved
Signed-off-by: Goutam <[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]>
Signed-off-by: Goutam <[email protected]>
|
/gemini summary |
Summary of ChangesThis pull request significantly refactors the write path in Ray Data to support datasinks that require schema information before data is written. It introduces a deferred Highlights
Changelog
Activity
|
Signed-off-by: Goutam <[email protected]>
| def _get_schema_from_bundle(self, bundle: RefBundle) -> Optional["pa.Schema"]: | ||
| """Extract PyArrow schema from a RefBundle. | ||
| For Arrow schemas, returns directly. For Pandas blocks, runs a lightweight | ||
| remote task to convert a 1-row sample to Arrow and extract the schema. | ||
| This ensures schema consistency with actual block conversion logic without | ||
| fetching block data to the driver. | ||
| """ | ||
| import pyarrow as pa |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this an Operator's method (we're not using self, there's no overriding in subclasses, etc)
| if isinstance(datasink, _FileDatasink): | ||
| if not datasink.has_created_dir and datasink.mode == SaveMode.IGNORE: | ||
| if datasink._pre_flight_check(): | ||
| logger.info( | ||
| f"Ignoring write because {datasink.path} already exists" | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just make this on_write_start, don't create another method (unnecessarily)
Signed-off-by: Goutam <[email protected]>
| datasink.on_write_start() | ||
| if datasink._skip_write: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leave a TODO to clean this up -- there'd be no special-casing for skipped writes
Description
This change defers writing until it reads the schema from the 1st bundle. This is needed for datasinks like Iceberg which require the schema to be mutated prior to writing the underlying data to the store.
Related issues
Additional information