Skip to content

Implement LogicalPlanBuilder::from for Arc<LogicalPlan> #10465

@alamb

Description

@alamb

For historical reasons children in LogicalPlan are Arc<LogicalPlan> (so shared, immutable references)

For many optimizer optimizations we need a owned LogicalPlan

This can be achieved via unwrap_arc

However, as pointed out by #10460 (comment) @ClSlaid it is not obvious at first

Today to get a builder from a plan you need to know this pattern:

// the builder accepts LogicalPlan only, so get one via unwrap_arc
let mut builder = LogicalPlanBuilder::from(unwrap_arc(plan));

I think it would be great to support this pattern:

// the builder accepts Arc<LogicalPlan> directly
let mut builder = LogicalPlanBuilder::from(plan);

And the underlying impl From<Arc<LogicalPlan>> for LogicalPlanBuilder would call unwrap_arc

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions