Skip to content

[release][Data] Cherry-pick "Fuse shuffle map with map op" (#68433) onto releases/2.61.0 - #68472

Merged
elliot-barn merged 1 commit into
releases/2.61.0from
elliot-barn/2.61.0-pick-68433
Nov 23, 2026
Merged

elliot-barn merged 1 commit into
releases/2.61.0from
elliot-barn/2.61.0-pick-68433

Conversation

@elliot-barn

Copy link
Copy Markdown
Collaborator

Description

Cherry-pick of #68433 (1729626bbb) onto releases/2.61.0. Lets the upstream read or map fuse into the disk-shuffle writer, and sets the polars thread limit inside the task rather than through the runtime env.

The pick applied without conflicts. Seven master commits that touch the same files are not on the release branch (#67143, #68158, #68202 and its revert #68383, #68319, #67570, #68118), so the picked files differ from master in five places. Reviewers from Data, please confirm none of those is a prerequisite.

Testing

Ran locally against the releases/2.61.0 wheel (7c8ca5ea51) with the picked files overlaid: test_hash_shuffle_v2.py, test_operator_fusion.py and test_execution_optimizer_advanced.py, 232 passed, 2 skipped.

🤖 Generated with Claude Code

## Description
Lets the upstream read or map fuse into the disk-shuffle writer, so one
task reads, maps, partitions and writes its shuffle file.
Also set polars max threads in task instead of runtime env so shuffle
map can fuse with other map op (or it'll blocked by different runtime
env )

---------

Signed-off-by: You-Cheng Lin <[email protected]>
(cherry picked from commit 1729626)
Signed-off-by: elliot-barn <[email protected]>
@elliot-barn
elliot-barn requested a review from a team as a code owner November 23, 2026 07:22

@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 enables map fusion for disk-based hash shuffles by introducing the DiskShuffleMap logical operator and setting the Polars thread cap inside the task rather than via a runtime environment. This allows upstream reads and maps to fuse directly into the shuffle writer. However, a critical bug was identified in map_operator.py where the DiskShuffleMap class is defined in the middle of the AbstractMap class definition, which will break AbstractMap and its subclasses by incorrectly scoping subsequent methods.

Comment on lines +122 to +145
@dataclass(frozen=True, repr=False, eq=False, init=False)
class DiskShuffleMap(AbstractMap):
"""Logical identity of a disk-shuffle writer (``plan_disk_hash_shuffle_map``).

The writer is a plain task-pool map, but the planner would tag it with the
shuffle's logical op (Repartition, Sort, Aggregate, Join), which map fusion
can't reason about. The plan function tags the writer with this op instead
so the upstream read or map fuses into it like into any other map. Not
user-facing: it never appears in a logical plan.
"""

def __init__(
self,
name: str,
input_op: Optional[LogicalOperator],
ray_remote_args: Optional[Dict[str, Any]] = None,
):
super().__init__(
name,
[input_op] if input_op is not None else [],
# The writer emits one handle row per task, unrelated to its input.
can_modify_num_rows=True,
ray_remote_args=ray_remote_args,
)

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.

critical

Defining DiskShuffleMap at the module level here interrupts the class definition of AbstractMap. As a result, the subsequent _get_args method (and any other methods defined after it with 4-space indentation) will be incorrectly attached to DiskShuffleMap instead of AbstractMap. This will break all other subclasses of AbstractMap (such as MapBatches, Filter, FlatMap) because they will lose their _get_args implementation.\n\nPlease remove DiskShuffleMap from this position and define it at the end of the file (or at least after the full definition of AbstractMap is complete).

Suggested change
@dataclass(frozen=True, repr=False, eq=False, init=False)
class DiskShuffleMap(AbstractMap):
"""Logical identity of a disk-shuffle writer (``plan_disk_hash_shuffle_map``).
The writer is a plain task-pool map, but the planner would tag it with the
shuffle's logical op (Repartition, Sort, Aggregate, Join), which map fusion
can't reason about. The plan function tags the writer with this op instead
so the upstream read or map fuses into it like into any other map. Not
user-facing: it never appears in a logical plan.
"""
def __init__(
self,
name: str,
input_op: Optional[LogicalOperator],
ray_remote_args: Optional[Dict[str, Any]] = None,
):
super().__init__(
name,
[input_op] if input_op is not None else [],
# The writer emits one handle row per task, unrelated to its input.
can_modify_num_rows=True,
ray_remote_args=ray_remote_args,
)
\n

@elliot-barn
elliot-barn merged commit 1040569 into releases/2.61.0 Nov 23, 2026
4 of 5 checks passed
@elliot-barn
elliot-barn deleted the elliot-barn/2.61.0-pick-68433 branch November 23, 2026 08:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants