Skip to content

Move large LogicalPlan arms out of DefaultPhysicalPlanner::map_logical_node_to_physical #26300

Open

Description

@andygrove

Is your feature request related to a problem or challenge?

DefaultPhysicalPlanner::map_logical_node_to_physical (physical_planner.rs#L593-L1978) is a single 1,203-line match over LogicalPlan, with cognitive complexity 202 and cyclomatic complexity 122. physical_planner.rs has had 80 commits in the last 12 months, so concurrent planner work regularly conflicts in this one function.

The match over variants is natural, but many arms carry large inline bodies:

  • Join (about L1372-L1844, ~470 lines, selecting between hash, sort-merge, nested-loop and cross joins)
  • Aggregate (about L1010-L1197)
  • Copy and the five Dml arms (about L693-L932)
  • Window

Some arms already delegate to helpers (e.g. Projection, Explain, Analyze), so the pattern is established.

Describe the solution you'd like

Keep the top-level match as a one-line-per-arm dispatcher and move each large arm into a private method on DefaultPhysicalPlanner: plan_join (further split by join algorithm), plan_aggregate, plan_window, plan_copy, plan_dml (one method for the five Dml arms), and so on. Do it incrementally, one arm per PR, starting with Join and Aggregate. Optionally move them into submodules (physical_planner/join.rs, aggregate.rs, dml.rs).

Describe alternatives you've considered

Leave it as is, at the cost of continued merge conflicts and harder review of planner changes.

Additional context

Line references are pinned to commit 0d79252.

Activity

  1. added
    enhancementNew feature or request
    help wantedExtra attention is needed
    coreCore DataFusion crate
    tech debtCode complexity, duplication or structure that makes the codebase harder to change
    on Oct 14, 2026
  2. LiXuanqi commented on Oct 21, 2026

    @LiXuanqi

    take

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

coreCore DataFusion crateenhancementNew feature or requesthelp wantedExtra attention is neededtech debtCode complexity, duplication or structure that makes the codebase harder to change

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions