Split the hour into 15 mins, add new column for every 15 min time frame and respective sum.
Here I have used the window function: How to group by time interval in Spark SQL, can someone help how to add hour_part column or any approach other than window function.
Input:
id,datetime,quantity
1234,2018-01-01 12:00:21,10
1234,2018-01-01 12:01:02,20
1234,2018-01-01 12:10:23,10
1234,2018-01-01 12:20:19,25
1234,2018-01-01 12:25:20,25
1234,2018-01-01 12:28:00,25
1234,2018-01-01 12:47:25,10
1234,2018-01-01 12:58:00,40
OutPut:
id,date,hour_part,sum
1234,2018-01-01,1,40
1234,2018-01-01,2,75
1234,2018-01-01,3,0
1234,2018-01-01,4,50