Thanks for reaching out to Microsoft Q&A.
Your syntax seems mostly correct, but there might be a few adjustments needed. Here's a refined version of your code:
import delta
from delta.tables import *
# Load the Delta table
Factevents = DeltaTable.forPath(spark, 'abfss://*******************.dfs.core.windows.net/silver/C365/events/')
# Merge new data
(
Factevents.alias('events')
.merge(
dfNewData.alias('New'),
"events.uprn = New.uprn AND events.id = New.id"
)
.whenMatchedUpdateAll()
.whenNotMatchedInsertAll()
.execute()
)
Here are a few steps to check:
- Data Types: Ensure that the data types of
uprn
andid
columns in bothevents
andNew
are the same. - Null Values: Check for any null values in the
uprn
orid
columns that might be causing issues. - Primary Key: Make sure that the combination of
uprn
andid
is unique in both datasets.
I hope the above steps will resolve the issue, please do let us know if issue persists. Thank you