@Joceph Moreno : Based on the information you have provided, it seems like you are specifying the partition keys in the ON condition of the merge statement. However, you should be using the partition columns in the USING clause of the merge statement instead.
Csn you check if the below works for you?
MERGE INTO delta.<path of delta table> oldData
USING (
SELECT * FROM df WHERE year = '2023' AND month = '10' AND day = '12'
) newData
ON oldData.clientid = newData.clientid
WHEN MATCHED THEN DELETE;
In this example, the partition columns (year, month, day) are used in the subquery in the USING clause to filter the data being merged. The partition columns are not included in the ON condition, as they are already being used to filter the data. Instead, the clientid column is used in the ON condition to match records between the old and new data. With this approach, the merge operation should only apply to the partition containing the data that matches the filter condition in the USING clause, which should improve performance.
Please let us know if this helps.