geoffreyclaude commented on code in PR #22559:
URL: https://github.com/apache/datafusion/pull/22559#discussion_r3311078311
##########
datafusion/physical-plan/src/execution_plan.rs:
##########
@@ -718,20 +738,32 @@ pub trait ExecutionPlan: Any + Debug + DisplayAs + Send +
Sync {
impl dyn ExecutionPlan {
/// Returns `true` if the plan is of type `T`.
///
+ /// If this plan provides a [`ExecutionPlan::downcast_delegate`], delegates
+ /// to it.
+ ///
/// Prefer this over `downcast_ref::<T>().is_some()`. Works correctly when
/// called on `Arc<dyn ExecutionPlan>` via auto-deref.
pub fn is<T: ExecutionPlan>(&self) -> bool {
- (self as &dyn Any).is::<T>()
+ match self.downcast_delegate() {
+ Some(delegate) => delegate.is::<T>(),
+ None => (self as &dyn Any).is::<T>(),
+ }
Review Comment:
The previous PR would stop on the first match, rather than go all the way to
the leaf child. I agree this is being pedantic, as "real world" cases would
probably never have a case where you'd need to match the leaf child but get
interrupted by an intermediate node in a "wrapper chain". However, I still find
the current implementation clearer and easier to reason about: the leaf node is
what is returned.
--
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]