Iterate rows and columns in Spark dataframe

前端 未结 7 1002
囚心锁ツ
囚心锁ツ 2020-12-23 12:32

I have the following Spark dataframe that is created dynamically:

val sf1 = StructField(\"name\", StringType, nullable = true)
val sf2 = StructField(\"sector         


        
相关标签:
7条回答
  • 2020-12-23 13:05

    sqlDF.foreach is not working for me but Approach 1 from @Sarath Avanavu answer works but it was also playing with the order of the records sometime.

    I found one more way which is working

    df.collect().foreach { row =>
       println(row.mkString(","))
    }
    
    0 讨论(0)
提交回复
热议问题