alamb opened a new issue, #10505:
URL: https://github.com/apache/datafusion/issues/10505

   ### Is your feature request related to a problem or challenge?
   
   This API is used in several optimizer passes to recursively find all column 
references in an expression
   
   pub fn 
[Expr::to_columns](https://docs.rs/datafusion/latest/datafusion/logical_expr/enum.Expr.html#method.to_columns)(&self)
 -> 
[Result](https://doc.rust-lang.org/nightly/core/result/enum.Result.html)<[HashSet](https://doc.rust-lang.org/nightly/std/collections/hash/set/struct.HashSet.html)<[Column](https://docs.rs/datafusion/latest/datafusion/common/struct.Column.html)>,
 
[DataFusionError](https://docs.rs/datafusion/latest/datafusion/common/enum.DataFusionError.html)>
   
   However, it requires `clone()` ing all `Columns` (which requires allocating 
and copying a string) even if the caller only needs to check if there is a 
reference. This is inefficient and leads to a slower optimizer
   
   
   ### Describe the solution you'd like
   
   I would like an API that does not require copying
   
   
   
   ### Describe alternatives you've considered
   
   One version might be this (returned hasset has `&Expr` not `Expr)
   
   ```rust
   impl Expr {
     /// Return all referenced  `Column`s  anywhere in this `Expr` 
     ///
     /// For example 
     /// * `a+b` would return `{a,b}`
     /// * `a + 1 + a` would return `{a}`
     fn column_refs(&self) -> HashSet<&Expr>  { 
     ...
     }
   ``` 
   
   
   
   ### Additional context
   
   _No response_


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