scala - Spark : How to union all dataframe in loop

前端 未结 6 1685
抹茶落季
抹茶落季 2020-12-14 22:41

Is there a way to get the dataframe that union dataframe in loop?

This is a sample code:

var fruits = List(
  \"apple\"
  ,\"orange\"
  ,\"melon\"
)          


        
6条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-14 22:57

    If you have different/multiple dataframes you can use below code, which is efficient.

    val newDFs = Seq(DF1,DF2,DF3)
    newDFs.reduce(_ union _)
    

提交回复
热议问题