viirya commented on code in PR #7565:
URL: https://github.com/apache/arrow-datafusion/pull/7565#discussion_r1327691485


##########
datafusion/physical-expr/src/aggregate/first_last.rs:
##########
@@ -237,13 +231,17 @@ impl Accumulator for FirstValueAccumulator {
         };
         if !ordered_states[0].is_empty() {
             let first_row = get_row_at_idx(&ordered_states, 0)?;
-            let first_ordering = &first_row[1..];
+            // When collecting orderings, we exclude the is_set flag from the 
state.
+            let first_ordering = &first_row[1..is_set_idx];
             let sort_options = get_sort_options(&self.ordering_req);
             // Either there is no existing value, or there is an earlier 
version in new data.
             if !self.is_set
                 || compare_rows(first_ordering, &self.orderings, 
&sort_options)?.is_lt()

Review Comment:
   It is not shorter. Actually, this fix makes them same length. Previously 
`first_ordering` has more one element (`is_set`).



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

Reply via email to