jayzhan211 commented on code in PR #25196:
URL: https://github.com/apache/datafusion/pull/25196#discussion_r3998428707


##########
datafusion/functions-aggregate/src/first_last.rs:
##########
@@ -1246,7 +1251,12 @@ impl AggregateUDFImpl for LastValue {
             )
             .into(),
         ];
-        fields.extend(args.ordering_fields.iter().cloned());
+        fields.extend(args.ordering_fields.iter().enumerate().map(|(idx, 
field)| {

Review Comment:
   could we add helper to reduce duplication
   
   ```rs
   /// Namespaces ordering fields so state field names stay unique per query.
   pub fn ordering_state_fields(name: &str, ordering_fields: &[FieldRef]) -> 
Vec<FieldRef> {
       ordering_fields
           .iter()
           .enumerate()
           .map(|(idx, f)| {
               Arc::new(f.as_ref().clone().with_name(format_state_name(
                   name,
                   &format!("ordering_{idx}_{}", f.name()),
               )))
           })
           .collect()
   }
   ```



##########
datafusion/functions-aggregate/src/first_last.rs:
##########
@@ -1246,7 +1251,12 @@ impl AggregateUDFImpl for LastValue {
             )
             .into(),
         ];
-        fields.extend(args.ordering_fields.iter().cloned());
+        fields.extend(args.ordering_fields.iter().enumerate().map(|(idx, 
field)| {

Review Comment:
   I think the first idx might be enough 🤔 
   
   first_value(value)[ordering_0_timestamp@0] becomes 
first_value(value)[ordering_0]



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