I have a data set with key pairs of values ββlike this
likes=dogs;hates=birds;likes=sports;eats=cheese
Then i will turn it into json
{"likes": ["dogs","sports"], "hates": ["birds"], "eats": ["cheese"]}
Is there a way to save this json data structure without dropping it onto a row, so I can get more columns from it row by row? I would like it to look something like this, without having to decrypt json from the row in each column.
Dataset<Row> df1 = df.withColumn("interests", callUDF("to_json", col("interests"))) .withColumn("likes", callUDF("extract_from_json", "likes", col("interests"))) .withColumn("hates", callUDF("extract_from_json", "hates", col("interests"))) .withColumn("hates", callUDF("extract_from_json", "eats", col("interests")));
source share