AnsweredAssumed Answered

Hive in built greatest() is not working

Question asked by hvalluri on Jan 30, 2018
Latest reply on Jan 30, 2018 by Hao Zhu

I have a requirement to calculate greatest value in multiple columns.

Input:

namesub1sub2sub3
st1101215
st2503035
st3151813

expected output:

namemax_sub
st115
st250
st318

When I try to use greatest function as below, I'm getting

select name,greatest(sub1,sub2,sub3) from student;

Failed with exception java.io.IOException:org.apache.hadoop.hive.ql.metadata.HiveException: Error evaluating greatest(sub1,sub2,sub3)

I'm using below as alternative. but, would like to know the issue with greatest.

select sort_array(arr)[size(arr)-1] from (select array(sub1,sub2,sub3) as arr from student)x;

hive Version : 1.2

Attachments

Outcomes