My requirement is to get the max count of decrease in values
Below is my input dataset:
+---+-------+
| id| amount|
+---+-------+
| 1| 10.0|
| 1| 9.0|
| 1| 7.0|
| 1| 6.0|
| 2| 50.0|
| 2| 60.0|
| 2| 70.0|
| 3| 90.0|
| 3| 80.0|
| 3| 90.0|
+---+-------+
and my required outcome is as below:
+---+--------+
| id| outcome|
+---+--------+
| 1| 3|
| 2| 0|
| 3| 2|
+---+--------+
My outcome (new column) is based on group by id and how many times the value has decreased consecutively for 3 times. For id 1 even though it reduced 4 times, I want only max of 3 times.
Any suggestion or help will be greatly appreciated in spark sql or spark dataframe(scala).