v.20.10Bug Fix

Fixed Duplicate Rows Caused by Incorrect Optimization in DISTINCT Queries

Fixed duplicates after DISTINCT which were possible because of incorrect optimization. Fixes #17294. #17296 (li chengxiang). #17439 (Nikolai Kochetov).