I have a pyspark Dataframe spark version < 2.4
Example dataframe:
column_1<Array> | column_2 <Array> | column_3 <Array> | join_columns
----------------------------------------------------------------------------------------------------------------------------------------
["2345", "98576", "09857"] | null | ["9857"] | ["2345", "98576", "09857", "9857"]
----------------------------------------------------------------------------------------------------------------------------------------
null | ["87569", "9876"] | ["76586"] | ["87569", "9876","76586"]
----------------------------------------------------------------------------------------------------------------------------------------
["08798","07564"] | ["12345","5768","89687","7564"] | ["7564"] | ["08798","07564","12345","5768","89687", "7564"]
----------------------------------------------------------------------------------------------------------------------------------------
["03456", "09867"] | ["87586"] | [] | ["03456", "09867","87586"]
------------------------------------------------------------------------------------------------------------------------------------------
I would like to combine the 3 columns column_1, column_2 and column_3 in one "join_columns" and to drop the duplicates values.
I used concat, it combined the 3 columns but only when I have only one value in the column, because may be "concat" is working only on Strings
df.withColumn("join_columns", concat(df.s, df.d)).drop_duplicates()
How can I combine the values of array columns ? Thank you