Hi All,
We are trying to run a MERGE statement on a delta table within a synapse spark 2.4 pool but getting the error
AnalysisException: INSERT, UPDATE and DELETE cannot appear twice in one MERGE query;
Traceback (most recent call last):File "/usr/hdp/current/spark2-client/jars/delta-core_2.11-0.6.1.1.jar/delta/tables.py", line 589, in execute
self._jbuilder.execute()
The statement to run the merge is as follows
tgttable.alias("tgtt") \
.merge(df.alias("tmpt"), "tgtt.merge_hash = tmpt.merge_hash") \
.whenMatchedUpdate(condition = "tgtt.hash_type2 != tmpt.hash_type2", set = {"current_record":"N", "row_to_datetime": "tmpt.ROW_FROM_DATETIME"}) \
.whenMatchedUpdate(condition = "tgtt.hash_type1 != tmpt.hash_type1", set = allCols) \
.execute()
According to documentation, unless I'm reading it badly, a merge statement should allow two whenMatchedUpdate statements so can anyone identify what I've done wrong?
Running just a single whenMatchedUpdate works fine
Thanks