21.8.4.51 / 21.9.2.17
select cnt from (select count() cnt where 0) where cnt = 0;
0 rows in set. Elapsed: 0.002 sec.
select cnt from (select count() cnt from system.one where 0) where cnt = 0;
0 rows in set. Elapsed: 0.001 sec.
select sum from (select sum(dummy) sum from system.one where 0) where sum = 0;
0 rows in set. Elapsed: 0.001 sec.
set aggregate_functions_null_for_empty=1;
select sum from (select sum(dummy) sum from system.one where 0)where sum is null ;
0 rows in set. Elapsed: 0.002 sec.
-- workaround to prevent pushdown
select cnt from (select count() cnt where 0 limit 1000000000) where cnt = 0;
┌─cnt─┐
│ 0 │
└─────┘
20.8.18.32 / 21.3.16.5 / 21.5.9 / 21.7.9.7 -- correct result
select cnt from (select count() cnt where 0) where cnt = 0;
┌─cnt─┐
│ 0 │
└─────┘
select cnt from (select count() cnt from system.one where 0) where cnt = 0;
┌─cnt─┐
│ 0 │
└─────┘
select sum from (select sum(dummy) sum from system.one where 0) where sum = 0;
┌─sum─┐
│ 0 │
└─────┘
set aggregate_functions_null_for_empty=1;
select sum from (select sum(dummy) sum from system.one where 0)where sum is null ;
┌──sum─┐
│ ᴺᵁᴸᴸ │
└──────┘
fixed in https://github.com/ClickHouse/ClickHouse/pull/28975