I am trying to write a query in hive to return a data with the year range if they are consecutive years along with the gap year, if there are gaps between the years.
I am trying to get my head around it, but can't seem to find the logic to achieve the results. How does hive logic work for this. Please help.
Input
group_no year
1111 2003
1111 2004
1111 2005
1111 2008
1111 2010
1111 2011
1111 2012
2222 2015
3333 2014
3333 2015
3333 2017
3333 2019
4444 2010
4444 2012
Output:
group_no year
1111 [2003-2005,2008,2010-2012]
2222 [2015]
3333 [2014-2015,2017,2019]
4444 [2010,2012]