Is there a way to get the dataframe that union dataframe in loop?
This is a sample code:
var fruits = List( \"apple\" ,\"orange\" ,\"melon\" )
You could created a sequence of DataFrames and then use reduce:
DataFrame
reduce
val results = fruits. map(fruit => Seq(("aaa", "bbb", fruit)).toDF("aCol","bCol","name")). reduce(_.union(_)) results.show()