Open windtalker opened 3 months ago
For the first query, we cannot remove the group-by directly because the result is different for an empty table whether it's a group-by agg or just a global agg.
It seems that an RBO rule needs to be added. I will try to handle this issue.
Enhancement
Consider the following cases
If there is no implict cast in expr
id = 1
, thenid
should be a constant column after filter, it can be removed from the group by keys, that is the optimizer should rewrite the sql to