Hello,
I would like to UPDATE the data in the delta table. For the same MERGE option came to my attention.
However my below code ends up with errors as shown at the end. Kindly advice what am I missing here. Thank you.
************************************************************************
from delta.tables import *
import pandas as pd
dfsource = pd.DataFrame({'BRI': {0: 'abc'},
'run_datetime': {0: '2022-12-05 16:33:22.324'}
})
tabletoupdate = DeltaTable.forName(spark, 'eda_rw.eda_log_bridge_run')
tabletoupdate.alias('target') \
.merge(
dfsource,
'target.BRI = dfsource.BRI'
'target.run_datetime = dfsource.run_datetime'
) \
.whenMatchedUpdate(set =
{
"BRI": "dfsource.BRI",
"run_datetime": "dfsource.run_datetime"
}
) \
.whenNotMatchedInsert(values =
{
"BRI": "dfsource.BRI",
"run_datetime": "dfsource.run_datetime"
}
) \
.execute()
**************************************************************************
Viren