8000 Fixed `Unknown identifier (aggregate-function)` exception which appears when a user tries to calculate WINDOW ORDER BY/PARTITION BY expressions over aggregate functions — backport of ClickHouse/ClickHouse#39762 by quickhouse · Pull Request #189 · Altinity/ClickHouse · GitHub
[go: up one dir, main page]

Skip to content

Fixed Unknown identifier (aggregate-function) exception which appears when a user tries to calculate WINDOW ORDER BY/PARTITION BY expressions over aggregate functions — backport of ClickHouse/ClickHouse#39762 - #189

Merged
Enmk merged 1 commit into
Altinity:customizations/22.3from
quickhouse:backportbetterorderbyoptimization
Aug 11, 2022

Conversation

@quickhouse
@quickhouse quickhouse commented Aug 4, 2022 •
Copy link
Copy Markdown

Changelog category (leave one):

  • Bug Fix (user-visible misbehaviour in official stable or prestable release)

Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Fixed Unknown identifier (aggregate-function) exception which appears when a user tries to calculate WINDOW ORDER BY/PARTITION BY expressions over aggregate functions:

CREATE TABLE default.tenk1
(
    `unique1` Int32,
    `unique2` Int32,
    `ten` Int32
)
ENGINE = MergeTree
ORDER BY tuple()
SETTINGS index_granularity = 8192;
SELECT
    ten,
    sum(unique1) + sum(unique2) AS res,
    rank() OVER (ORDER BY sum(unique1) + sum(unique2) ASC) AS rank
FROM _complex
GROUP BY ten
ORDER BY ten ASC;

which gives:

Code: 47. DB::Exception: Received from localhost:9000. DB::Exception: Unknown identifier: sum(unique1); there are columns: unique1, unique2, ten: While processing sum(unique1) + sum(unique2) ASC. (UNKNOWN_IDENTIFIER)

The bug was introduced in ClickHouse#34632 .

Backport of ClickHouse#39762

…`ExpressionAnalyzer`, shall be `aggregated_columns`.
@Enmk
Enmk merged commit 3242439 into Altinity:customizations/22.3 Aug 11, 2022
@Enmk Enmk mentioned this pull request Aug 16, 2022
@Enmk Enmk mentioned this pull request Sep 12, 2022
4 tasks done
Enmk pushed a commit that referenced this pull request Sep 17, 2022
…WINDOW ORDER BY/PARTITION BY

Fixed using `column_after_join` for handling `WINDOW` expressions in `ExpressionAnalyzer`, shall be `aggregated_columns`.
@Enmk Enmk mentioned this pull request Dec 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0