cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
cancel
Showing results for 
Search instead for 
Did you mean: 

Can merge() function be applied to dataframe?

andrew0117
Contributor

if I have two dataframes df_target and df_source, can I do df_target.as("t).merge(df_source.as("s"), "s.id=t.id").whenMatched().updateAll().whenNotMatched.insertAll.execute().

when I tried the code above, I got the error "merge is not a member of the dataframe". If that is the case, what is the best way to do it? Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions

pvignesh92
Honored Contributor

Hi @andrew li​ Merge functionality is a part of Delta Lake API and not native dataframe API. Only when you are writing the data in delta format, you can use this functionality.

Please check the below link to achieve Merge using delta lake API.

https://learn.microsoft.com/en-us/azure/databricks/delta/merge

View solution in original post

4 REPLIES 4

pvignesh92
Honored Contributor

Hi @andrew li​ Merge functionality is a part of Delta Lake API and not native dataframe API. Only when you are writing the data in delta format, you can use this functionality.

Please check the below link to achieve Merge using delta lake API.

https://learn.microsoft.com/en-us/azure/databricks/delta/merge

Aviral-Bhardwaj
Esteemed Contributor III

nice info

@Aviral Bhardwaj​ Please upvote 🙂

Anonymous
Not applicable

Hi @andrew li​ 

Hope all is well! Just wanted to check in if you were able to resolve your issue and would you be happy to share the solution or mark an answer as best? Else please let us know if you need more help. 

We'd love to hear from you.

Thanks!

Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.