Hi devs, While reading SqlSplittableAggFunction and AggregateJoinTransposeRule source code, I noticed that in CountSplitter.topSplit, it creates an SUM0 AggCall, which makes sense for the following query: select count(t1.a) from t1 join t2 on t1.b=t2.b;
which will be transformed to: select sum0(cnt*c) from (select b, count(a) as cnt from t1 group by b) t1 join (select b, count(*) as c from t2 group by b)t2 on t1.b=t2.b ; But for another query: select t1.b, count(t1.a) from t1 join t2 on t1.b=t2.b group by t1.b; which will be transformed to: select t1.b, sum0(cnt*c) from (select b, count(a) as cnt from t1 group by b) t1 join (select b, count(*) as c from t2 group by b)t2 on t1.b=t2.b group by t1.b; In fact, query without additional SUM0 group agg should be enough: select t1.b, cnt*c from (select b, count(a) as cnt from t1 group by b) t1 join (select b, count(*) as c from t2 group by b) t2 on t1.b=t2.b; Am I missing something? Correct me if I am wrong. Thanks~ Haisheng Yuan
