PushProjector has some code like this in "convertProject":
if (
(projRefs.cardinality() == nChildFields)
&& (childPreserveExprs.size() == 0)) {
return null;
Which, if I am following right, means when there aren't any preserve-exprs,
we will only push a project past a filter if the project is going to cut
down on the number of fields that go through the filter.
What's the rationale for that? In one case Im looking at, a query like:
SELECT dim1, SUM(cnt) / COUNT(*) GROUP BY dim1 HAVING SUM(cnt) / COUNT(*)
= 1
The plan ends up involving doing an aggregate -> filter on
SUM(cnt)/COUNT(*) = 1 -> project [dim1, SUM(cnt)/COUNT(*)]. Wouldn't it be
better to consider the possibility of doing this instead: aggregate ->
project [dim1, SUM(cnt)/COUNT(*)] -> filter on $1 = 1? Then the division
doesn't have to be done twice.
My hidden motivation for asking: Druid's Calcite rules currently can't
handle the former case but they probably would be able to handle the latter
:)
Gian