I need to add sequence number to each row I am processing in a dataframe. But everytime when I add, we need to get the max of sequence from the existing rows and add + 1 and assign it to new row.
Any idea How we can achieve this with dataframe in spark scala.
Example.
below is the existing data in a table:
row_id,emp_id, sal
1,11,2000
2,22,3000
Now I need to add new row as follows to the table:
3,33,5000
we need to get row id every time when we are inserting new data to the table by getting max(row_id) from the table and add +1 to it.
Please suggest any ideas.
Thanks,