You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "timsaucer (via GitHub)" <gi...@apache.org> on 2026/04/12 16:42:41 UTC

[PR] Remove `as_any` on the `PhysicalExpr` trait [datafusion]

timsaucer opened a new pull request, #21573:
URL: https://github.com/apache/datafusion/pull/21573

   ## Which issue does this PR close?
   
   - Addresses part of https://github.com/apache/datafusion/issues/21572
   
   ## Rationale for this change
   
   This PR reduces the amount of boilerplate code that users need to write for Physical Expressions.
   
   ## What changes are included in this PR?
   
   Now that we have [trait upcasting](https://blog.rust-lang.org/2025/04/03/Rust-1.86.0/) since rust 1.86, we no longer need every implementation of this trait to have the as_any function that returns &self. This PR makes Any an supertrait and makes the appropriate casts when necessary.
   
   ## Are these changes tested?
   
   Existing unit tests.
   
   ## Are there any user-facing changes?
   
   Yes, the users simply need to remove the as_any function. The upgrade guide is updated.
   


-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] Remove `as_any` on the `PhysicalExpr` trait [datafusion]

Posted by "timsaucer (via GitHub)" <gi...@apache.org>.
timsaucer commented on code in PR #21573:
URL: https://github.com/apache/datafusion/pull/21573#discussion_r3089024025


##########
docs/source/library-user-guide/upgrading/54.0.0.md:
##########


Review Comment:
   Great idea! 



-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] Remove `as_any` on the `PhysicalExpr` trait [datafusion]

Posted by "timsaucer (via GitHub)" <gi...@apache.org>.
timsaucer merged PR #21573:
URL: https://github.com/apache/datafusion/pull/21573


-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] Remove `as_any` on the `PhysicalExpr` trait [datafusion]

Posted by "nuno-faria (via GitHub)" <gi...@apache.org>.
nuno-faria commented on code in PR #21573:
URL: https://github.com/apache/datafusion/pull/21573#discussion_r3088884977


##########
docs/source/library-user-guide/upgrading/54.0.0.md:
##########


Review Comment:
   Not for this PR but the upgrade guide for these changes is becoming quite large. Wouldn't just a single example suffice?



-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] Remove `as_any` on the `PhysicalExpr` trait [datafusion]

Posted by "timsaucer (via GitHub)" <gi...@apache.org>.
timsaucer commented on code in PR #21573:
URL: https://github.com/apache/datafusion/pull/21573#discussion_r3069771301


##########
datafusion/physical-expr/src/intervals/cp_solver.rs:
##########
@@ -939,16 +938,8 @@ mod tests {
             Interval::make(Some(100), None)?,
             PropagationResult::Infeasible,
             &Schema::new(vec![
-                Field::new(
-                    left_col.as_any().downcast_ref::<Column>().unwrap().name(),
-                    DataType::Int32,
-                    true,
-                ),
-                Field::new(
-                    right_col.as_any().downcast_ref::<Column>().unwrap().name(),
-                    DataType::Int32,
-                    true,
-                ),

Review Comment:
   It looks at first glance like we're removing a check on the `Column` type but if you look higher up you can see that `left_col` is an `Arc<Column>` so this doesn't impact the test.



-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] Remove `as_any` on the `PhysicalExpr` trait [datafusion]

Posted by "timsaucer (via GitHub)" <gi...@apache.org>.
timsaucer commented on code in PR #21573:
URL: https://github.com/apache/datafusion/pull/21573#discussion_r3069778762


##########
datafusion/physical-expr/src/simplifier/unwrap_cast.rs:
##########
@@ -254,9 +249,7 @@ mod tests {
         let literal_expr = lit(10i64);
         let binary_expr =
             Arc::new(BinaryExpr::new(cast_expr, Operator::Gt, literal_expr));
-        let binary_ref = binary_expr.as_any().downcast_ref::<BinaryExpr>().unwrap();

Review Comment:
   Similar to above, this test didn't really do anything other than step through the as_any() function since binary_expr is already an `Arc<BinaryExpr>` 



-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org