Search code examples
hadoophivehiveql

Find Max value from a list in Hive


I need to find max value from a list in HIVE.

For eg: If i am having values [5,4,3] in a list i need to get 5.

max(list_name) is not working. Is there any workaround.


Solution

  • It might not be the most optimized, but it kinda works.

     select max(arr) from ( select explode( array(4, 5, 1, 20, 45, 47, 9) ) as arr ) t
    
    +------+--+
    | _c0  |
    +------+--+
    |  47  |
    +------+--+