I have requirement merge records in PySpark dataframe for overlapping dates.
MIN of start date and MAX of end data would be the start and end date of overlapped records.
Sample records:
Input data
Item Code Item name Start_date End_date
============== ========= =========== ===========
111 Item1 15-May-2004 20-Jun-2004
111 Item1 22-May-2004 07-Jun-2004
111 Item1 20-Jun-2004 13-Aug-2004
111 Item1 27-May-2004 30-Aug-2004
111 Item1 02-Sep-2004 23-Dec-2004
222 Item2 21-May-2004 19-Aug-2004
Output should be like
Item Code Item name Start_date End_date
============== ========= =========== ===========
111 Item1 15-May-2004 30-Aug-2004
111 Item1 02-Sep-2004 23-Dec-2004
222 Item2 21-May-2004 19-Aug-2004