timsaucer commented on code in PR #21263:
URL: https://github.com/apache/datafusion/pull/21263#discussion_r3029662596
##########
docs/source/library-user-guide/upgrading/54.0.0.md:
##########
@@ -180,29 +180,50 @@ function. The below diffs are examples from the
associated PRs.
}
```
-If you have a function that is downcasting a UDF, you can replace
-the call to `.as_any()` with `.as_ref() as &dyn Any`. For example
+**Execution Plans:**
+
+```diff
+ impl ExecutionPlan for MyExec {
+- fn as_any(&self) -> &dyn Any {
+- self
+- }
+-
+ fn name(&self) -> &'static str {
+ "MyExec"
+ }
+
+ ...
+ }
+```
+
+If you have code that is downcasting, you can use the new `downcast_ref`
+and `is` methods defined directly on each trait object:
**Before:**
```rust,ignore
-let is_async = func
- .inner()
- .as_any()
- .downcast_ref::<AsyncScalarUDF>()
- .is_some();
+let exec = plan.as_any().downcast_ref::<MyExec>().unwrap();
+let udf = scalar_udf.as_any().downcast_ref::<MyUdf>().unwrap();
```
**After:**
```rust,ignore
-let is_async = (func
- .inner()
- .as_ref() as &dyn Any)
- .downcast_ref::<AsyncScalarUDF>()
- .is_some();
+let exec = plan.downcast_ref::<MyExec>().unwrap();
+let udf = scalar_udf.downcast_ref::<MyUdf>().unwrap();
```
+These methods are available on `dyn ExecutionPlan`, `dyn ScalarUDFImpl`,
+`dyn AggregateUDFImpl`, and `dyn WindowUDFImpl`. They work correctly
+whether the value is a bare reference or behind an `Arc` (Rust
+auto-derefs through the `Arc`).
+
+> **Warning:** Do not cast an `Arc<dyn Trait>` directly to `&dyn Any`.
Review Comment:
Yes, so it renders like this:
<img width="759" height="252" alt="Screenshot 2026-04-02 at 2 31 26 PM"
src="https://github.com/user-attachments/assets/79ff1341-e695-4fc1-8764-223b1adb2b6c"
/>
--
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]