I have data in RDD which have 4 columns like geog, product, time and price. I want to calculate the running sum based on geog and time. 

Given Data

[![Source](https://i.stack.imgur.com/mxMRu.png)](https://i.stack.imgur.com/mxMRu.png)

I need result like. 

[![Need Output like this]](https://i.stack.imgur.com/PDy6i.png)

I need this spark-Scala-RDD. I am new to this Scala world, i can achieve this easily in SQL. i want do this in spark -Scala -RDD like using (map,flatmap).

Advance thanks for your help.