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


##########
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:
   The snippet is meant to illustrate the sentence immediately above it: you 
pair `acc_args.exprs` with `acc_args.schema` to recover the full `FieldRef` for 
argument *i*. 
   
   Pulling the metadata out of `schema.field(i)` is one common use case, and 
the follow-up line shows how you would then obtain the complete `FieldRef` 
(name, type, metadata) via:
   
   ```rust
   exprs[i].return_field(&acc_args.schema)
   ```
   
   ...using the same pairing.
   
   I'll tweak the wording.
   



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