v.22.5Performance Improvement

Allow rewriting countDistinct aggregation to subquery format

Allow to rewrite select countDistinct(a) from t to select count(1) from (select a from t groupBy a). #35993 (zhanglistar).