[
https://issues.apache.org/jira/browse/HIVE-1128?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Zheng Shao updated HIVE-1128:
-----------------------------
Description:
A lot of users are interested in doing "arg_min" and "arg_max". Basically,
return the value of some other columns when one column's value is the max value.
The following is an example usage when this is done:
{code}
SELECT department, max(struct(salary, employee_name))
FROM compensations
GROUP BY department;
SELECT department, max(struct(salary, employee_name)).col2 AS employee_name
FROM compensations
GROUP BY department;
SELECT department, sen.col1 as salary, sen.col2 as employee_name
FROM (
SELECT department, max(struct(salary, employee_name)) AS sen
FROM compensations
GROUP BY department
) tmp
{code}
was:
A lot of users are interested in doing "arg_min" and "arg_max". Basically,
return the value of some other columns when one column's value is the max value.
The following is an example usage when this is done:
{code}
SELECT department, max(struct(salary, employee_name))
FROM compensations
GROUP BY department;
SELECT department, max(struct(salary, employee_name)).col2 AS employee_name
FROM compensations
GROUP BY department;
SELECT department, sen.col1 as salary, sen.col2 as employee_name
FROM (
SELECT department, max(struct(salary, employee_name)).col2 AS sen
FROM compensations
GROUP BY department
) tmp
{code}
> Let max/min handle complex types like struct
> --------------------------------------------
>
> Key: HIVE-1128
> URL: https://issues.apache.org/jira/browse/HIVE-1128
> Project: Hive
> Issue Type: Improvement
> Affects Versions: 0.6.0
> Reporter: Zheng Shao
> Assignee: Zheng Shao
> Fix For: 0.6.0
>
> Attachments: HIVE-1128.1.sh, HIVE-1128.2.patch
>
>
> A lot of users are interested in doing "arg_min" and "arg_max". Basically,
> return the value of some other columns when one column's value is the max
> value.
> The following is an example usage when this is done:
> {code}
> SELECT department, max(struct(salary, employee_name))
> FROM compensations
> GROUP BY department;
> SELECT department, max(struct(salary, employee_name)).col2 AS employee_name
> FROM compensations
> GROUP BY department;
> SELECT department, sen.col1 as salary, sen.col2 as employee_name
> FROM (
> SELECT department, max(struct(salary, employee_name)) AS sen
> FROM compensations
> GROUP BY department
> ) tmp
> {code}
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)