adriangb commented on code in PR #26270:
URL: https://github.com/apache/datafusion/pull/26270#discussion_r4807388321


##########
datafusion/execution/src/task.rs:
##########
@@ -53,6 +69,71 @@ pub struct TaskContext {
     window_functions: HashMap<String, Arc<WindowUDF>>,
     /// Runtime environment associated with this task context
     runtime: Arc<RuntimeEnv>,
+    /// State that operators keep for one run of a plan
+    run_state: Arc<RunState>,

Review Comment:
   The per-run state also covers recursive queries. `RecursiveQueryExec` gives 
each iteration a child state with new outputs for the CTEs that its recursive 
term declares. A CTE declared outside the recursive term keeps one output for 
the whole query. Plan nodes no longer hold the output, so this needs no 
in-place `reset_state`. 
[449f12cf0](https://github.com/adriangb/datafusion/commit/449f12cf0bd37e90efab488eaa1505d08c5d0630)
 adds tests for nested recursive queries and for `UNION` (DISTINCT) recursion.
   
   On your `StateId` point: here the CTE id is that id. A producer and consumer 
pair such as TopK and a scan would fit the same pattern. The planner assigns 
the filter an id, the producer writes its bounds to the per-run state under 
that id, and the scan reads them in `execute`. I sketched this in 
[#28003](https://github.com/apache/datafusion/issues/28003).
   



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