timsaucer opened a new pull request, #23649:
URL: https://github.com/apache/datafusion/pull/23649

   ## Which issue does this PR close?
   
   - Alternative to 22340
   
   ## Rationale for this change
   
   When we turn logical plans into physical plans, we have a work around to get 
the context for scalar subqueries. Specifically we clone the session and mutate 
the `execution_props` where the subquery context currently sits. This is even 
called out in the code with comments:
   
   ```rust
               // Ideally, the subquery state would live in a dedicated planning
               // context rather than in `ExecutionProps`. It's here because
               // `create_physical_expr` only receives `&ExecutionProps`.
   ```
   
   The real reason for this is that we want to expose the `QueryPlanner` via 
FFI and currently it depends upon downcasts from `Session` to `SessionState`. 
That does not work for the FFI crate where we have a different `Session` 
implementation. Since we cannot do the downcast, we cannot use the work around 
in the current code.
   
   This PR is designed to plumb through the required context properly rather 
than rely on manipulating the execution properties.
   
   ## What changes are included in this PR?
   
   The major change here is to remove `subquery_indexes` and `subquery_results` 
from `ExecutionProps` and put them into their own struct `SubqueryContext`. 
Everything else is just refactoring and plumbing to align around this split of 
the data.
   
   ## Are these changes tested?
   
   - Existing unit tests all pass.
   - Added additional unit test to cover user defined expressions.
   
   ## Are there any user-facing changes?
   
   Yes, this adds a single parameter into `create_physical_expr`, the subquery 
context. The migration guide demonstrates how to add a default context in for 
users, if necessary.


-- 
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]

Reply via email to