icexelloss opened a new issue, #34908:
URL: https://github.com/apache/arrow/issues/34908

   ### Describe the enhancement requested
   
   Recently, this PR changes the ordering output columns of aggregation to
   `(hash)keys + segment_keys + aggregates`
   
(https://github.com/apache/arrow/blob/main/cpp/src/arrow/acero/aggregate_node.cc#L654)
   
   I wondering it makes more sense to change this to
   `segment_keys + (hash)keys + aggregates`
   
   My reasoning is as follows:
   This only really affects the result in the case of segmented aggregation so 
I will solely reasoning about segmented aggregation (in non-segmented 
aggregation, segment_keys is empty so the result wouldn't change regardless).
   
   In segmented aggregation, the hash key is used within each segment (i.e., we 
don't combine grouped from different segments together) so in a way, the hash 
key feels like "second key", i.e., data is first split up by segments, then by 
hash keys. And therefore, it feels more natural to order the output columns: 
primary key (segment keys) + secondary key (hash keys) + aggregates. 
   
   To give an example of time ordered aggregations (an application of segmented 
aggregations). where segment key = "time" and hash key = "id", we almost always 
wanted the output to be "time, id" instead of "id, time" because the full 
stream is time ordered so it makes sense to make that the first column.
   
   @westonpace I wonder what is your thoughts on switch this up? If you feel 
strongly about keeping the current order I think we might still be able to 
tweak this at the substrait level with emit output to get the order we want, 
but I figured it's probably easier / more consistent if we just switch up the 
default ordering.
   
   
    
   
   ### Component(s)
   
   C++


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