Reputation: 1027
Hive has min(col) to find the minimum value of a column. But how about finding the minimum of multiple values (NOT one column), for example
select min(2,1,3,4);
returns
FAILED: UDFArgumentTypeException Exactly one argument is expected
Any tips?
Upvotes: 2
Views: 7014
Reputation: 19
Use below to find the minimum value from multiple columns.
It will produce minimum value from each row.
select least(col1,col2) as least_value from table_name;
It will produce minimum value from all rows.
select min(least(col1,col2)) as least_value from table_name;
Upvotes: 0
Reputation:
Instead of using MIN, use LEAST method to find the minimum values form given values/columns^^rows.
select least(2,1,3,4);
Upvotes: 1
Reputation: 1027
Found the solution!
Instead of min(col)
, we should use least(a, b, c, d)
Upvotes: 5