I have two variables. One is a Dataframe and other is a List[Dataframe]. I wish to perform a join on these. At the moment I am using the following appoach:
def joinDfList(SingleDataFrame: DataFrame, DataFrameList: List[DataFrame], groupByCols: List[String]): DataFrame = {
var joinedDf = SingleDataFrame
DataFrameList.foreach(
Df => {
joinedDf = joinedDf.join(Df, groupByCols, "left_outer")
}
)
joinedDf.na.fill(0.0)
}
Is there an approach where we can skip usage of "var" and instead of "foreach" use "foldleft"?