Skip to content

Crash in avgWeighted with Decimal #32053

@UnamedRus

Description

@UnamedRus

Describe what's wrong

Crash with avgWeighted + Decimal in window function.

Does it reproduce on recent release?

Yes, 21.8-21.12

How to reproduce

SELECT avgWeighted(a, toDecimal64(c, 9)) OVER (PARTITION BY c) 
FROM
(
    SELECT
        number AS a,
        number AS c
    FROM numbers(10)
)

[LAPTOP-] 2021.12.01 15:41:35.721898 [ 8782 ] <Fatal> BaseDaemon: ########################################
[LAPTOP-] 2021.12.01 15:41:35.722020 [ 8782 ] <Fatal> BaseDaemon: (version 21.12.1.8922 (official build), build id: 0C2586E3E51E2F10) (from thread 8753) (query_id: 40d256f5-821d-4839-9510-d9477f430139) Received signal Arithmetic exception (8)
[LAPTOP-] 2021.12.01 15:41:35.722056 [ 8782 ] <Fatal> BaseDaemon: Integer divide by zero.
[LAPTOP-] 2021.12.01 15:41:35.722100 [ 8782 ] <Fatal> BaseDaemon: Stack trace: 0xa0783e8 0xa32a307 0xa473879 0x13f5ff6c 0x13f64d9f 0x13d99e23 0x13d8e0cf 0x13d8d589 0x13d8d31b 0x13d9d8e7 0xa0b9817 0xa0bd21d 0x7faa1cc23609 0x7faa1cb4a293
[LAPTOP-] 2021.12.01 15:41:35.722154 [ 8782 ] <Fatal> BaseDaemon: 2. ? @ 0xa0783e8 in /usr/bin/clickhouse
[LAPTOP-] 2021.12.01 15:41:35.722212 [ 8782 ] <Fatal> BaseDaemon: 3. DB::AvgFraction<DB::Decimal<wide::integer<128ul, int> >, DB::Decimal<wide::integer<128ul, int> > >::divideIfAnyDecimal(unsigned int, unsigned int) const @ 0xa32a307 in /usr/bin/clickhouse
[LAPTOP-] 2021.12.01 15:41:35.722246 [ 8782 ] <Fatal> BaseDaemon: 4. DB::AggregateFunctionAvgBase<DB::Decimal<wide::integer<128ul, int> >, DB::Decimal<wide::integer<128ul, int> >, DB::AggregateFunctionAvgWeighted<unsigned long, DB::Decimal<long> > >::insertResultInto(char*, DB::IColumn&, DB::Arena*) const @ 0xa473879 in /usr/bin/clickhouse
[LAPTOP-] 2021.12.01 15:41:35.722286 [ 8782 ] <Fatal> BaseDaemon: 5. DB::WindowTransform::appendChunk(DB::Chunk&) @ 0x13f5ff6c in /usr/bin/clickhouse
[LAPTOP-] 2021.12.01 15:41:35.722318 [ 8782 ] <Fatal> BaseDaemon: 6. DB::WindowTransform::work() @ 0x13f64d9f in /usr/bin/clickhouse
[LAPTOP-] 2021.12.01 15:41:35.722349 [ 8782 ] <Fatal> BaseDaemon: 7. DB::ExecutionThreadContext::executeTask() @ 0x13d99e23 in /usr/bin/clickhouse
[LAPTOP-] 2021.12.01 15:41:35.722381 [ 8782 ] <Fatal> BaseDaemon: 8. DB::PipelineExecutor::executeStepImpl(unsigned long, std::__1::atomic<bool>*) @ 0x13d8e0cf in /usr/bin/clickhouse
[LAPTOP-] 2021.12.01 15:41:35.722401 [ 8782 ] <Fatal> BaseDaemon: 9. DB::PipelineExecutor::executeImpl(unsigned long) @ 0x13d8d589 in /usr/bin/clickhouse
[LAPTOP-] 2021.12.01 15:41:35.722433 [ 8782 ] <Fatal> BaseDaemon: 10. DB::PipelineExecutor::execute(unsigned long) @ 0x13d8d31b in /usr/bin/clickhouse
[LAPTOP-] 2021.12.01 15:41:35.722461 [ 8782 ] <Fatal> BaseDaemon: 11. ? @ 0x13d9d8e7 in /usr/bin/clickhouse
[LAPTOP-] 2021.12.01 15:41:35.722497 [ 8782 ] <Fatal> BaseDaemon: 12. ThreadPoolImpl<std::__1::thread>::worker(std::__1::__list_iterator<std::__1::thread, void*>) @ 0xa0b9817 in /usr/bin/clickhouse
[LAPTOP-] 2021.12.01 15:41:35.722538 [ 8782 ] <Fatal> BaseDaemon: 13. ? @ 0xa0bd21d in /usr/bin/clickhouse
[LAPTOP-] 2021.12.01 15:41:35.722557 [ 8782 ] <Fatal> BaseDaemon: 14. ? @ 0x7faa1cc23609 in ?
[LAPTOP-] 2021.12.01 15:41:35.722587 [ 8782 ] <Fatal> BaseDaemon: 15. __clone @ 0x7faa1cb4a293 in ?
[LAPTOP-] 2021.12.01 15:41:36.050135 [ 8782 ] <Fatal> BaseDaemon: Calculated checksum of the binary: 88ED9424A7CA5CCF2B8DE36558700120. There is no information about the reference checksum.

SELECT  avgWeighted(a, toDecimal64(c,9)) OVER (PARTITION BY toDecimal64(c,9)) FROM ( SELECT number as a, number as c FROM numbers(10)); -- also crashes.

Expected behavior

Query works

Metadata

Metadata

Assignees

Labels

crashCrash / segfault / abort

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions