I have a sample dataframe in Spark Scala which contains one column and many other columns 50+ and need to explode id :
example data:
id n
Try this:
import org.apache.spark.sql.functions._ scala> df.withColumn("id", explode(split($"id", " "))).show +---+----+-------+ | id|name|address| +---+----+-------+ |234| auh| aus| |435| auh| aus| |567| auh| aus| |345|muji| uk| |123|muji| uk| +---+----+-------+