user2895589 user2895589 - 18 days ago 10
Scala Question

How to select all columns of a dataframe in join - Spark-scala

I am doing join of 2 data frames and select all columns of left frame for example:

val join_df = first_df.join(second_df, first_df("id") === second_df("id") , "left_outer")


in above I want to do select first_df.* .How can I select all columns of one frame in join ?

Answer

With alias:

first_df.alias("fst").join(second_df, Seq("id"), "left_outer").select("fst.*")