SNOW-3485471: cte dedup for self-join case (#4245)