Fix upsert dupliate insertion error on aggregation.