I have the following Spark dataframe that is created dynamically:
val sf1 = StructField(\"name\", StringType, nullable = true) val sf2 = StructField(\"sector
You can convert Row to Seq with toSeq. Once turned to Seq you can iterate over it as usual with foreach, map or whatever you need
Row
Seq
toSeq
foreach
map
sqlDF.foreach { row => row.toSeq.foreach{col => println(col) } }
Output:
Berta bbb 30 Joe Andy aaa 20 ccc 40