avantgardnerio commented on issue #10630:
URL: https://github.com/apache/datafusion/issues/10630#issuecomment-2127035893

   > > GroupedTopKAggregateStream
   > 
   > I believe @avantgardnerio / @thinkharderdev worked on this code, as part 
of #7192
   > 
   > I agree it is strange to be using that operator given a SQL without an 
aggregate. I thought it only kicked in if there was a `MIN` or `MAX` aggregate 🤔
   
   I'm surprised this is being invoked, because: 
   
   ```
           // ensure the sort direction matches aggregate function
           let (field, desc) = aggr.get_minmax_desc()?;
           if desc != order.options.descending {
               return None;
           }
   ```
   
   and 
   
   ```
       /// Finds the DataType and SortDirection for this Aggregate, if there is 
one
       pub fn get_minmax_desc(&self) -> Option<(Field, bool)> {
           let agg_expr = self.aggr_expr.as_slice().first()?;
           if let Some(max) = agg_expr.as_any().downcast_ref::<Max>() {
               Some((max.field().ok()?, true))
           } else if let Some(min) = agg_expr.as_any().downcast_ref::<Min>() {
               Some((min.field().ok()?, false))
           } else {
               None
           }
       }
   ```


-- 
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: github-unsubscr...@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to