Skip to content

Resolve physical placeholders#23

Open
LLDay wants to merge 2 commits intoaskalt/bump-candidatefrom
dsemenov/resolve-placeholders
Open

Resolve physical placeholders#23
LLDay wants to merge 2 commits intoaskalt/bump-candidatefrom
dsemenov/resolve-placeholders

Conversation

@LLDay
Copy link

@LLDay LLDay commented Feb 4, 2026

Rationale for this change

Currently, DataFusion's support for placeholders is handled at the logical plan level. This requires re-planning every time parameter values change.

This PR introduces physical-level support for placeholders, allowing a physical plan to be created once and then executed multiple times with different parameter values. This should improve performance for repeated executions of the same query with different parameters by avoiding the overhead of physical planning.

What changes are included in this PR?

This PR introduces several key components to support physical placeholders:

PlaceholderExpr: A new physical expression that represents a placeholder in the physical plan. It stores the placeholder ID and its data type.
TransformPlanExec: A new execution plan node that can rewrite execution plans at execution time.
PhysicalExprResolver Optimizer Rule: Wraps the final optimized plan in a TransformPlanExec if any unresolved placeholders are detected.
TaskContext Update: Updated to carry ParamValues.

Are these changes tested?

TransformPlanExec and PhysicalExprResolver are tested with unit tests and SLT tests.

Are there any user-facing changes?

Yes, a user can now build physical plan from a logical plan with placeholders.

Copy link

@askalt askalt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! The generalization looks good to me. We could combine all stuff needed to re-use plan in single rule and wrap the plan with it.

Introduces `PlaceholderExpr`, allowing placeholder parameters to be
preserved in the physical plan. Previously, placeholders had to be
resolved to literals before physical planning.
@LLDay LLDay force-pushed the dsemenov/resolve-placeholders branch from 904da3e to 0691772 Compare February 5, 2026 12:59
This commit introduces a mechanism to resolve placeholders in the
execution plans.

It adds a new `TransformPlanExec` that allows replacing
`PlaceholderExpr` with values from `TaskContext` during the execution
phase.

This enables physical plan reuse for queries with parameters.
@LLDay LLDay force-pushed the dsemenov/resolve-placeholders branch from 0691772 to d02b869 Compare February 5, 2026 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants