ClickHouse/tests/queries/0_stateless/01690_quantilesTiming_ubsan.sql
Azat Khuzhin 984445b44b Fix UBsan reports in quantileTiming
UBsan reports [1]:

    ../src/AggregateFunctions/QuantileTiming.h:442:27: runtime error: 1.84467e+19 is outside the range of representable values of type 'unsigned long' Received signal -3 Received signal Unknown signal (-3)

  [1]: https://clickhouse-test-reports.s3.yandex.net/19971/e15f5d9cb5b36482d1ae9ca069074fb200f2ab37/fuzzer_ubsan/report.html#fail1

Follow-up for: #19394
2021-02-04 02:01:48 +03:00

32 lines
1.3 KiB
SQL

-- NOTE: that due to overflows it may give different result before
-- quantilesTimingWeighted() had been converted to double:
--
-- Before:
--
-- SELECT quantilesTimingWeighted(1)(number, 9223372036854775807)
-- FROM numbers(2)
--
-- ┌─quantilesTimingWeighted(1)(number, 9223372036854775807)─┐
-- │ [1] │
-- └─────────────────────────────────────────────────────────┘
--
-- After:
--
-- SELECT quantilesTimingWeighted(1)(number, 9223372036854775807)
-- FROM numbers(2)
--
-- ┌─quantilesTimingWeighted(1)(number, 9223372036854775807)─┐
-- │ [0] │
-- └─────────────────────────────────────────────────────────┘
SELECT quantilesTimingWeighted(0.1)(number, 9223372036854775807) FROM numbers(2);
-- same UB, but in the inner loop
SELECT quantilesTimingWeighted(0, 0.001, 0.01, 0.05, 0.1, 0.2, 0.3, 0.4, 0.6, 0.7, 0.8, 0.9, 0.95, 0.99, 0.999, 1)(number, 9223372036854775807)
FROM
(
SELECT number
FROM system.numbers
LIMIT 100
);