LLDay opened a new pull request, #20009: URL: https://github.com/apache/datafusion/pull/20009
## Rationale for this change This PR covers a part of #14342. 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: 1. **Expression Rewriting Interface**: Added `physical_expressions` and `with_physical_expressions` to the `ExecutionPlan` trait to allow inspection and replacement of expressions within plan nodes. 2. **`PlaceholderExpr`**: A new physical expression that represents a placeholder in the physical plan. It stores the placeholder ID and its data type. 3. **`ResolvePlaceholdersExec`**: A new execution plan node that acts as a wrapper. It identifies placeholders within its subtree and resolves them using parameter values provided at execution time. 4. **`PhysicalExprResolver` Optimizer Rule**: Wraps the final optimized plan in a `ResolvePlaceholdersExec` if any unresolved placeholders are detected. 5. **`TaskContext` Update**: Updated to carry `ParamValues`. ## Are these changes tested? - The new `physical_expressions` and `with_physical_expressions` methods are verified using the [`check_physical_expressions`](https://github.com/apache/datafusion/blob/d51359f8dcda1f64ed3e8c24a60b5e6b5661d10f/datafusion/core/src/physical_planner.rs#L2527-L2537) invariant. - `ResolvePlaceholdersExec` is 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. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
