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

Ensure ROLLUP and CUBE respect HAVING (no change to TOTALS) #3837

Merged
merged 2 commits into from
Dec 17, 2018

Conversation

reflection
Copy link
Contributor

I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=en

Fixes #3756 . Tests match postgres output now.

ubuntu :) select * from test.rollup_having;

SELECT *
FROM test.rollup_having

┌─a────┬─b────┐
│ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │
└──────┴──────┘
┌─a─┬─b────┐
│ a │ ᴺᵁᴸᴸ │
└───┴──────┘
┌─a─┬─b─┐
│ a │ b │
└───┴───┘

3 rows in set. Elapsed: 0.006 sec.

ubuntu :) SELECT a, b, count(*) FROM test.rollup_having GROUP BY a, b WITH ROLLUP HAVING a IS NOT NULL;

SELECT
    a,
    b,
    count(*)
FROM test.rollup_having
GROUP BY
    a,
    b
    WITH ROLLUP
HAVING isNotNull(a)

┌─a─┬─b────┬─count()─┐
│ a │ ᴺᵁᴸᴸ │       1 │
│ a │ b    │       1 │
└───┴──────┴─────────┘
┌─a─┬─b────┬─count()─┐
│ a │ ᴺᵁᴸᴸ │       2 │
└───┴──────┴─────────┘

3 rows in set. Elapsed: 0.007 sec.

ubuntu :) SELECT a, b, count(*) FROM test.rollup_having GROUP BY a, b WITH ROLLUP HAVING a IS NOT NULL and b IS NOT NULL;

SELECT
    a,
    b,
    count(*)
FROM test.rollup_having
GROUP BY
    a,
    b
    WITH ROLLUP
HAVING isNotNull(a) AND isNotNull(b)

┌─a─┬─b─┬─count()─┐
│ a │ b │       1 │
└───┴───┴─────────┘

1 rows in set. Elapsed: 0.005 sec.

ubuntu :) SELECT a, b, count(*) FROM test.rollup_having GROUP BY a, b WITH ROLLUP WITH TOTALS HAVING a IS NOT NULL;

SELECT
    a,
    b,
    count(*)
FROM test.rollup_having
GROUP BY
    a,
    b
    WITH ROLLUP
    WITH TOTALS
HAVING isNotNull(a)

┌─a─┬─b────┬─count()─┐
│ a │ ᴺᵁᴸᴸ │       1 │
│ a │ b    │       1 │
└───┴──────┴─────────┘
┌─a─┬─b────┬─count()─┐
│ a │ ᴺᵁᴸᴸ │       2 │
└───┴──────┴─────────┘

Totals:
┌─a────┬─b────┬─count()─┐
│ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │       2 │
└──────┴──────┴─────────┘

3 rows in set. Elapsed: 0.009 sec.

ubuntu :) SELECT a, b, count(*) FROM test.rollup_having GROUP BY a, b WITH ROLLUP WITH TOTALS HAVING a IS NOT NULL and b IS NOT NULL;

SELECT
    a,
    b,
    count(*)
FROM test.rollup_having
GROUP BY
    a,
    b
    WITH ROLLUP
    WITH TOTALS
HAVING isNotNull(a) AND isNotNull(b)

┌─a─┬─b─┬─count()─┐
│ a │ b │       1 │
└───┴───┴─────────┘

Totals:
┌─a────┬─b────┬─count()─┐
│ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │       1 │
└──────┴──────┴─────────┘

@alexey-milovidov alexey-milovidov merged commit 14df9c7 into ClickHouse:master Dec 17, 2018
@alexey-milovidov
Copy link
Member

Thank you!

PS. Single integration test has failed - false positive.

alexey-milovidov added a commit that referenced this pull request Jan 16, 2019
alexey-milovidov added a commit that referenced this pull request Jan 16, 2019
alexey-milovidov added a commit that referenced this pull request Jan 16, 2019
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