ClickHouse/tests/queries/0_stateless/03131_rewrite_sum_if_nullable.sql
2024-04-24 18:53:29 +02:00

21 lines
1.1 KiB
SQL

-- https://github.com/ClickHouse/ClickHouse/issues/62890
-- { echoOn }
SELECT sum(if(materialize(0), toNullable(1), 0));
SELECT sum(if(materialize(0), toNullable(1), materialize(0)));
SELECT sum(if(materialize(0), materialize(toNullable(1)), materialize(0)));
SELECT sum(if(materialize(0), materialize(1), materialize(0)));
SELECT sum(if(dummy, 0, toNullable(0)));
SELECT sum(if(dummy, materialize(0), toNullable(0)));
SELECT sum(if(dummy, materialize(0), materialize(toNullable(0))));
SELECT sum(if(s == '', v, 0)) b from VALUES ('v Nullable(Int64), s String',(1, 'x'));
SELECT sumOrNull(if(materialize(0), toNullable(1), 0));
SELECT sumOrNull(if(materialize(0), 1, 0));
SELECT sum(if(materialize(0), toNullable(1), 0)) settings aggregate_functions_null_for_empty=1;
SELECT sum(if(materialize(0), 1, 0)) settings aggregate_functions_null_for_empty=1;
SELECT sumOrNull(if(materialize(1), toNullable(1), 10));
SELECT sumOrNull(if(materialize(1), 1, 10));
SELECT sum(if(materialize(1), toNullable(1), 10)) settings aggregate_functions_null_for_empty=1;
SELECT sum(if(materialize( 1), 1, 10)) settings aggregate_functions_null_for_empty=1;