user2895589 user2895589 - 1 year ago 272
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 Source

With alias:

first_df.alias("fst").join(second_df, Seq("id"), "left_outer").select("fst.*")
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download