Skip to content

Instantly share code, notes, and snippets.

@upidea
upidea / getmaxidfromarray.sql
Created June 28, 2018 11:30
get max index of an array by hive sql
with example_table as (
select 1 as docid, array(3, 5, 8, 2) as rate union all
select 2 as docid, array(4, 7, 3, 8) as rate union all
select 3 as docid, array(6, 8, 3, 6) as rate
)
select
docid,
rate,
array_indexof(rate, frate)
from