I have a List list =["a","b","c"] and i have to add a new column to my dataframe, but first i have to construct it and this column have to be like:
x|y|z|list
strings in my list are columns, i mean that i have to construct my request like :
SELECT x,y,z, list FROM Dataframe
I tried to split strings in the list with
String.join("," , list)
but it is seen like a singl column not multiple columns
Dataset<Row> df= dataframe.withColumn("NewColumn", concat(dataframe.col("x"), lit("|"), dataframe.col("y"),lit("|"), String.join(","list));
Note 1: the size of my list is editable and the columns too Note 2: i have to call String.join(","list) in my function withColumn, i don't have the choice
the expected result is a dataframe :
------------------------------------------------------------
x y z a b c **NewColumn**
------------------------------------------------------------
val1 val2 val3 val4 val5 val6 val1|val2|val3|val4|val5|val6
-------------------------------------------------------------
I don't see how to construct my new column, thank you for your help