[Data][Cherry-pick] Prevent Limit from getting pushed past map_groups (#60881)#60893
Merged
aslonnie merged 2 commits intoreleases/2.54.0from Feb 10, 2026
Merged
[Data][Cherry-pick] Prevent Limit from getting pushed past map_groups (#60881)#60893aslonnie merged 2 commits intoreleases/2.54.0from
Limit from getting pushed past map_groups (#60881)#60893aslonnie merged 2 commits intoreleases/2.54.0from
Conversation
This PR updates `map_groups` to assume that the UDF might change the row count. This change is necessary to fix a bug where `Limit` gets incorrectly pushed past the `map_groups` (fixes #60872). For more context, see: * #60448 * #60756 --------- Signed-off-by: Balaji Veeramani <bveeramani@berkeley.edu>
Contributor
There was a problem hiding this comment.
Code Review
This pull request addresses a bug in Ray Data's optimizer where a Limit operation could be incorrectly pushed down past a map_groups operation. The map_groups operation was incorrectly marked as not modifying row counts, which is now fixed by setting udf_modifying_row_count=True. This ensures that optimizations like limit pushdown are not applied when they could lead to incorrect results. A new test case has been added to verify that the Limit operation is no longer pushed past map_groups by default, confirming the fix. The changes are correct and well-tested.
alexeykudinkin
approved these changes
Feb 9, 2026
iamjustinhsu
approved these changes
Feb 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cherry-pick of #60881