jayshrivastava commented on code in PR #24226:
URL: https://github.com/apache/datafusion/pull/24226#discussion_r3750579635
##########
datafusion/physical-plan/src/execution_plan.rs:
##########
Review Comment:
Ideally what we want is this
```rust
pub fn apply_expression_roots<I>(
roots: I,
f: &mut dyn FnMut(&Arc<dyn PhysicalExpr>) -> Result<TreeNodeRecursion>,
) -> Result<TreeNodeRecursion>
where
I: IntoIterator,
I::Item: AsRef<Arc<dyn PhysicalExpr>>,
{
for root in roots {
match f(root.as_ref())? {
TreeNodeRecursion::Stop => return Ok(TreeNodeRecursion::Stop),
TreeNodeRecursion::Continue | TreeNodeRecursion::Jump => {}
}
}
Ok(TreeNodeRecursion::Continue)
}
```
However, `AsRef<Arc<dyn PhysicalExpr>>` is surprisingly implemented for
`Arc<dyn PhysicalExpr>`. We cannot add this implementation due to the orphan
rule. `AsRef` is foreign and `Arc` is foreign.
This PR gets around the problem by adding a new type, `PhysicalExprRoot` but
that new type makes this refactor seem less worthwhile.
--
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]