You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@arrow.apache.org by "David Li (Jira)" <ji...@apache.org> on 2022/02/07 13:18:00 UTC
[jira] [Comment Edited] (ARROW-13993) [C++] Hash aggregate function that returns value from first row in group
[ https://issues.apache.org/jira/browse/ARROW-13993?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17488095#comment-17488095 ]
David Li edited comment on ARROW-13993 at 2/7/22, 1:17 PM:
-----------------------------------------------------------
Yes, we just want a single row per group. Any row will do; the point above is that we can't implement anything else (because the query engine currently lacks support for ordering, beyond sorting outputs at the very end).
All hash_ kernels ("hash aggregate kernels") are in [{{hash_aggregate.cc}}|https://github.com/apache/arrow/blob/master/cpp/src/arrow/compute/kernels/hash_aggregate.cc] and it will be very similar to the CountDistinct/Distinct implementation there.
was (Author: lidavidm):
Yes, we just want a single tuple. Any tuple will do; the point above is that we can't implement anything else (because the query engine currently lacks support for ordering, beyond sorting outputs at the very end).
All hash_ kernels ("hash aggregate kernels") are in [{{hash_aggregate.cc}}|https://github.com/apache/arrow/blob/master/cpp/src/arrow/compute/kernels/hash_aggregate.cc] and it will be very similar to the CountDistinct/Distinct implementation there.
> [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)