Skip to content

Fix *If combinator with unary function and Nullable types#18806

Merged
alexey-milovidov merged 1 commit intoClickHouse:masterfrom
azat:If-combinator-Nullable-fix
Jan 7, 2021
Merged

Fix *If combinator with unary function and Nullable types#18806
alexey-milovidov merged 1 commit intoClickHouse:masterfrom
azat:If-combinator-Nullable-fix

Conversation

@azat
Copy link
Copy Markdown
Member

@azat azat commented Jan 7, 2021

Changelog category (leave one):

  • Bug Fix

Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Fix *If combinator with unary function and Nullable types

Detailed description / Documentation draft:
sumIf(Nullable()) and similar unary functions (unary w/o If combinator)
was working incorrectly, since it returns "sum" from the getName()
helper, and so distributed query processing fails.

The problem is in the optimization in
AggregateFunctionIfNullUnary::add() for the unary functions. It pass
only one column to write result to, instead of all passed arguments +
result columns.
While AggregateFunctionIf::add() assumes that it accepts arguments +
result columns, and use last column as a result.

Introduced-in: #16610
Fixes: #18210
Cc: @zhang2014

sumIf(Nullable()) and similar unary functions (unary w/o If combinator)
was working incorrectly, since it returns "sum" from the getName()
helper, and so distributed query processing fails.

The problem is in the optimization in
AggregateFunctionIfNullUnary::add() for the unary functions. It pass
only one column to write result to, instead of all passed arguments +
result columns.
While AggregateFunctionIf::add() assumes that it accepts arguments  +
result columns, and use last column as a result.

Introduced-in: ClickHouse#16610
Fixes: ClickHouse#18210
@robot-clickhouse robot-clickhouse added the pr-bugfix Pull request with bugfix, not backported by default label Jan 7, 2021
@alexey-milovidov alexey-milovidov self-assigned this Jan 7, 2021
@alexey-milovidov alexey-milovidov merged commit b73722e into ClickHouse:master Jan 7, 2021
@azat azat deleted the If-combinator-Nullable-fix branch January 7, 2021 13:00
robot-clickhouse pushed a commit that referenced this pull request Jan 7, 2021
robot-clickhouse pushed a commit that referenced this pull request Jan 7, 2021
robot-clickhouse pushed a commit that referenced this pull request Jan 7, 2021
robot-clickhouse pushed a commit that referenced this pull request Jan 7, 2021
alexey-milovidov added a commit that referenced this pull request Jan 10, 2021
Backport #18806 to 20.12: Fix *If combinator with unary function and Nullable types
alexey-milovidov added a commit that referenced this pull request Jan 10, 2021
Backport #18806 to 20.11: Fix *If combinator with unary function and Nullable types
alexey-milovidov added a commit that referenced this pull request Jan 10, 2021
Backport #18806 to 20.10: Fix *If combinator with unary function and Nullable types
alexey-milovidov added a commit that referenced this pull request Jan 15, 2021
Fix *If combinator with unary function and Nullable types
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-bugfix Pull request with bugfix, not backported by default

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remote Query Execution with sumIf() function faling

3 participants