Queries with `count(case when [cond] then 1 else null end)` fail to plan
mwylde opened this issue · comments
Queries of the structure
select
count(case when action = 'click' then 1 else null end),
from stream
group by tumble(interval '1 second');
Currently fail to plan, with an error like
expected aggregate function, not COUNT(CASE WHEN stream.action = Utf8("click")
THEN Int64(1) ELSE Int64(NULL) END) AS COUNT(CASE WHEN stream.action = Utf8("click")
THEN Int64(1) ELSE NULL END)
However, other case statements do work correctly, for example:
sum(case when action = 'click' then 1 else 0 end)
This appears to be an issue with how we identify aggregate expressions within an alias (caused here by the implicit type conversion due to the null)