Kristofferjoha commented on issue #19905:
URL: https://github.com/apache/datafusion/issues/19905#issuecomment-7354575610

   @raghavyadav01 just trying some different stuff for rebinding locally while 
we settle on the design.
   
   @alamb From what i can tell, `map_expressions` makes sense for the filter 
readers, but once you account for the other state copies share, like scalar 
subqueries and materialized CTEs, I don't think it's enough on its own. 
`ScalarSubqueryExec` keeps its results in a field rather than an expression, 
and copies made with `rese_plan_states` share it. If i make two copies of 
`SELECT x FROM t WHERE x > (SELECT avg(x) FROM t)` up front and run them one 
after the other, the second fails saying index 0 was already populated. The CTE 
buffer is also a field on the plan nodes, not an expression.
   
   CTEs made me wonder how far those bindings need to reach. A CTE scan holds 
its buffer directly, and a scan inside a scalar subquery can sit outside the 
producer’s subtree. That’s why `MaterializedCteBinder` already walks the whole 
plan (docs also mentioned a different reason about scancs being planned before 
the node that owns their CTE). Could we keep the old-to-new bindings around for 
the whole copy, use `map_expressions` for the expression readers, and bind plan 
nodes like the CTE scan directly?


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