Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optimize_rewrite_sum_if_to_count_if breaks window functions #31620

Closed
filimonov opened this issue Nov 22, 2021 · 1 comment · Fixed by #32453
Closed

optimize_rewrite_sum_if_to_count_if breaks window functions #31620

filimonov opened this issue Nov 22, 2021 · 1 comment · Fixed by #32453
Labels
bug Confirmed user-visible misbehaviour in official release comp-optimizers Query optimizations comp-window-functions

Comments

@filimonov
Copy link
Contributor

filimonov commented Nov 22, 2021

select
    if(number % 10 = 0, 1, 0) AS dummy,
    sum(dummy) OVER w
FROM numbers(10)
WINDOW w AS (ORDER BY number ASC ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW);

SET optimize_rewrite_sum_if_to_count_if = 1

-- Received exception from server (version 21.11.1):
-- Code: 215. DB::Exception: Received from localhost:9000. DB::Exception: Column `number` is not under aggregate function and not in GROUP BY: While processing if((number % 10) = 0, 1, 0) AS dummy, countIf((number % 10) = 0). (NOT_AN_AGGREGATE)

SET optimize_rewrite_sum_if_to_count_if = 0

-- works 

@filimonov filimonov added comp-optimizers Query optimizations comp-window-functions potential bug To be reviewed by developers and confirmed/rejected. bug Confirmed user-visible misbehaviour in official release and removed potential bug To be reviewed by developers and confirmed/rejected. labels Nov 22, 2021
@filimonov
Copy link
Contributor Author

Similar #31535

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Confirmed user-visible misbehaviour in official release comp-optimizers Query optimizations comp-window-functions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant