Home > Back-end >  Union returns dataset - Spark 3.1.2
Union returns dataset - Spark 3.1.2

Time:12-27

There are two dataframes mergeDF_A and mergeDF_B. The below union action is giving a dataset instead of dataframe. Why is it returning a dataset? And how to get a dataframe?

val finalMergeDF = mergeDF_A.union(mergeDF_B).distinct()

CodePudding user response:

You can convert dataset to dataframe using toDF():

mergeDF_A.union(mergeDF_B).toDF()
  • Related