Skip to content

-If combinator and NULLs #16231

@mkabilov

Description

@mkabilov

Clickhouse version: 20.9.2 revision 54439

SELECT
    sumMapIf([1], [1], nullIf(number, 3) > 0) AS col1,
    countIf(1, nullIf(number, 3) > 0) AS col2,
    sumIf(1, nullIf(number, 3) > 0) AS col3
FROM numbers(1, 5)

col1 is expected to be ([1],[4]) as NULLs must be skipped
col3 value is expected to be the same as col2's as the condition part is identical and both should return 4

in fact we get the following values:

┌─col1──────┬─col2─┬─col3─┐
│ ([1],[5]) │    4 │    5 │
└───────────┴──────┴──────┘

as a workaround one can wrap the condition part with coalesce(..., 0)

Metadata

Metadata

Assignees

Labels

bugConfirmed user-visible misbehaviour in official releasemajor

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions