I am performing merge operation on databricks delta table as below -
spark.sql(""" MERGE INTO <delta table name> deltatbl USING <temp view> source
ON deltatbl.col1 = source.col1
AND deltatbl.col2 = source.col2
WHEN NOT MATCHED THEN INSERT
(col1,col2) VALUES(source.Col1,source.Col2) """)
Above query is inserting duplicates records despite matching unique keys. How I can achieve an output where only non matching records are inserted. all columns are part of key.