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

SQL Merge condition

Julie285720
New Contributor

Hi guys 🙂 

I have a question regarding this merge step and I am a new beginner for Databricks, trying to do some study in data warehousing, but couldn't figure it out by myself. need your help with it. Appreciate your help in advance. 

I got this question after using the merge condition, my people10mupdates became empty. So what did happen? 

Julie285720_0-1693869289599.png

LInk for this practice. 

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

1 REPLY 1

Kaniz
Community Manager
Community Manager

Hi @Julie285720The merge operation in Databricks upserts data from a source table into a target table.

In your case, the source table  people10mupdates and the target table is people10m.

The merge operation works as follows:
- It matches each record in the source table with the target table based on the condition provided in the ON clause. In your case, it's matching records where people10m.id = people10mupdates.id.
- If a match is found (WHEN MATCHED), it updates the existing record in the target table with the corresponding record from the source table.
- If no match is found (WHEN NOT MATCHED), it inserts the record from the source table into the target table. If your people10mupdates table became empty after the merge operation, it might be because all records were matched, updated, or inserted into the people10m table. 

However, the merge operation does not delete records from the source table (people10mupdates in your case). If the people10mupdates table is empty, it might be due to another operation or process that deleted or moved the records.

Please check if any other operations or processes might be affecting the people10mupdates table.

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.