For 'N' farmers on the invoice each owner will be split 'N' times. I want the row to split as per expected output in spark scala.
source Data:
INVNUM PRODNUM CUSTNAME LANDOWNERS
1 1 Sonu farmer
1 1 Ramu farmer
1 1 Alec owner
1 1 Prashanth owner
Expected output:
INVNUM PRODNUM CUSTNAME Shareownername
1 1 Sonu Sonu --> same name here as Sonu is Farmer
1 1 Ramu Ramu --> same name here as Ramu is Farmer
1 1 Alec Sonu --> split two times for Sonu and Ramu as sharewoner for Alec
1 1 Alec Ramu
1 1 Prashanth Sonu --> split twice Sonu and Ramu as sharewoner for Prashanth
1 1 Prashanth Ramu