I can join dataframes in scala like this and it works;
df1.join(df2, df1("id") === df2("id"), "left").select(df1("id"),df2("name"))
I want to use nvl function on df2.name column like nvl(df2.name,"test")
How can I handle this with spark scala ?
thanks in advance
CodePudding user response:
You can use coalece and lit from spark.sql.functions
df1.join(df2, df1("id") === df2("id"), "left").select(df1("id"),coalesce(df2("name"),lit("test")))