anoopunni
New Contributor II

Hi,
I have come across same scenario, using reduce() and unionByname we can implement the solution as below:

val lstDF: List[Datframe] = List(df1,df2,df3,df4,df5)

val combinedDF = lstDF.reduce((df1, df2) => df1.unionByName(df2, allowMissingColumns = true))

#Scala # Spark #multiple schema