You are right, UNION ALL keeps duplicates but UNION does not.

So the UNION has no duplicates taking into account the 7 columns, but your unique key is only on the 5 first columns, it happens that you must have duplicates of the 5 first columns but columns 6 & 7 different for these "duplicates".

for instance :

1 2 3 4 5 10 100
1 2 3 4 5 10 101

HTH & regards,

rbaraer