更新时间:2023-11-18 21:30:10
您可以使用 toSeq
将 Row
转换为 Seq
.一旦转向 Seq
,你可以像往常一样使用 foreach
、map
或任何你需要的东西
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
sqlDF.foreach { row =>
row.toSeq.foreach{col => println(col) }
}
输出:
Berta
bbb
30
Joe
Andy
aaa
20
ccc
40