cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
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

AviralBhardwaj

@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!

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you won’t want to miss the chance to attend and share knowledge.

If there isn’t a group near you, start one and help create a community that brings people together.

Request a New Group