ClickHouse/tests/queries/0_stateless/01668_avg_weighted_ubsan.sql
tavplubix 6c16348faa
Fix division by zero in avgWeighted with Decimal argument (#32303)
* fix division by zero

* Update src/AggregateFunctions/AggregateFunctionAvg.h

Co-authored-by: Dmitry Novik <n0vik@clickhouse.com>

* remove trash

* Update AggregateFunctionAvg.h

Co-authored-by: Dmitry Novik <n0vik@clickhouse.com>
2021-12-07 13:32:26 +03:00

6 lines
433 B
SQL

SELECT round(avgWeighted(x, y)) FROM (SELECT 1023 AS x, 1000000000 AS y UNION ALL SELECT 10 AS x, -9223372036854775808 AS y);
select avgWeighted(number, toDecimal128(number, 9)) from numbers(0);
SELECT avgWeighted(a, toDecimal64(c, 9)) OVER (PARTITION BY c) FROM (SELECT number AS a, number AS c FROM numbers(10));
select avg(toDecimal128(number, 9)) from numbers(0);
select avgWeighted(number, toDecimal128(0, 9)) from numbers(10);