Reply
Highlighted
New Contributor
Posts: 2
Registered: ‎04-24-2017

How to append the preceding rows for the same key for different dates in hive

I have a scenario like below. can anyone please provide some info.

 

I have the below table. i tried doing this using join with lag and lead function but its not giving the expected result. I'm just not getting any clue how to implement the solution for this.

Input table

 

name date amount
abc 04/06/2018 100
abc 04/06/2018 200
abc 04/13/2018 300 


now the output i needed is below.

 

name date amount
abc 04/06/2018 100
abc 04/06/2018 200
abc 04/13/2018 100
abc 04/13/2018 200
abc 04/13/2018 300


so here 300 is the new value for 04/13/2018 and 100,200 from 04/06/2018 will also shown for 04/13/2018.

Do we have any way to do this in hive. Any help will be greatly appreciated.

Announcements