[ 
https://issues.apache.org/jira/browse/ARROW-13993?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17488089#comment-17488089
 ] 

Dhruv Vats commented on ARROW-13993:
------------------------------------

Just so I understand this correctly (as I don't have a very formal CS 
background), when we do:
{code:sql}
SELECT country, SUM(customerID) FROM db_table GROUP BY country{code}
from a supposed sales table {{db_table}} that has fields {{country}} and 
{{{}customerID{}}}, we get number of customers _per_ country/group.

So here instead sum of all tuples in a group, we just want to return a single 
tuple from the different groups/country? And, it seems _which_ tuple (like 
either the first or a specific one) to return is yet to be finalised, right?

Also is there a PR or an existing kernel that has a similar boilerplate code to 
what this will have? (That'll save a disproportionate time going through all 
the abstractions).

> [C++] Hash aggregate function that returns value from first row in group
> ------------------------------------------------------------------------
>
>                 Key: ARROW-13993
>                 URL: https://issues.apache.org/jira/browse/ARROW-13993
>             Project: Apache Arrow
>          Issue Type: Improvement
>          Components: C++
>            Reporter: Ian Cook
>            Assignee: Dhruv Vats
>            Priority: Major
>              Labels: good-second-issue, kernel
>             Fix For: 8.0.0
>
>
> It would be nice to have a hash aggregate function that returns the first 
> value of a column within each hash group.
> If row order within groups is non-deterministic, then effectively this would 
> return one arbitrary value. This is a very computationally cheap operation.
> This can be quite useful when querying a non-normalized table. For example if 
> you have a table with a {{country}} column and also a {{country_abbr}} column 
> and you want to group by either/both of those columns but return the values 
> from both columns, you could do
> {code:java}
> SELECT country, country_abbr FROM table GROUP BY country, country_abbr{code}
> but it would be more efficient to do
> {code:java}
> SELECT country, first(country_abbr) FROM table GROUP BY country{code}
> because then the engine does not need to scan all the values of the 
> {{country_abbr}} column.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to