Joining Spark dataframes on the key

后端 未结 8 2157
情书的邮戳
情书的邮戳 2020-11-28 03:02

I have constructed two dataframes. How can we join multiple Spark dataframes ?

For Example :

PersonDf, ProfileDf with a common col

8条回答
  •  萌比男神i
    2020-11-28 03:30

    you can use

    val resultDf = PersonDf.join(ProfileDf, PersonDf("personId") === ProfileDf("personId"))
    

    or shorter and more flexible (as you can easely specify more than 1 columns for joining)

    val resultDf = PersonDf.join(ProfileDf,Seq("personId"))
    

提交回复
热议问题