I have a dataframe with single array struct column where I want to split the nested values and added as a comma separated string new column(s) Example dataframe: tests
{id:1,name:foo},{id:2,name:bar}
Expected result dataframe
tests tests_id tests_name
[id:1,name:foo],[id:2,name:bar] 1, 2 foo, bar
I tried the below code but got an error
df.withColumn("tests_name", concat_ws(",", explode(col("tests.name"))))
Error:
org.apache.spark.sql.AnalysisException: Generators are not supported when it's nested in expressions, but got: concat_ws(,, explode(tests.name AS `name`));