kosiew commented on code in PR #17085:
URL: https://github.com/apache/datafusion/pull/17085#discussion_r2394701655


##########
datafusion/expr/src/udaf.rs:
##########
@@ -762,7 +762,24 @@ pub trait AggregateUDFImpl: Debug + DynEq + DynHash + Send 
+ Sync {
     /// group during query execution.
     ///
     /// acc_args: [`AccumulatorArgs`] contains information about how the
-    /// aggregate function was called.
+    /// aggregate function was called. Use `acc_args.exprs` together with
+    /// `acc_args.schema` to inspect the [`FieldRef`] of each input.
+    ///
+    /// Example: retrieving metadata and return field for input `i`:
+    /// ```ignore
+    /// let metadata = acc_args.schema.field(i).metadata();
+    /// let field = acc_args.exprs[i].return_field(&acc_args.schema)?;
+    /// ```

Review Comment:
   Not at all 😄 
   
   * `acc_args.schema.field(i)` — returns the raw Arrow `Field` from the 
(physical) input schema at position `i` (name, type, nullability, metadata 
exactly as in that schema).
   
   * `acc_args.exprs[i].return_field(&acc_args.schema)?` — asks the expression 
for the effective `FieldRef` for argument `i` given the full schema. It 
incorporates expression semantics (casts, literals, computed types, extension 
metadata, nullability changes, etc.) and returns an owned/Arc `FieldRef` (and 
can fail), not just a borrowed `&Field`.
   



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