I would like to make a comparison between two df1 df2 dataframes on the list_id column :
df1 =
+---------+
| list_id|
+---------+
|[1, 2, 3]|
|[4, 5, 6]|
|[7, 8, 9]|
+---------+
df2 =
+------------+
| list_id|
+------------+
| [10, 3, 11]|
|[12, 13, 14]|
| [15, 6, 16]|
+------------+
The desired result is:
df2 =
+-------------------+
| list_id|
+-------------------+
| [1, 2, 3, 10, 11] |
| [4, 5, 6, 15, 16] |
| [7, 8, 9] |
| [12, 13, 14] |
+-------------------+
My aim is to concatenate lists where their intersection is not empty and to keep the others as is with pyspark.
Note: my dataframes are very large, the use of a join with Spark Sql is impossible.