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

Wrong value of TOTALS in function maxMap #57686

Closed
CurtizJ opened this issue Dec 8, 2023 · 0 comments · Fixed by #57795
Closed

Wrong value of TOTALS in function maxMap #57686

CurtizJ opened this issue Dec 8, 2023 · 0 comments · Fixed by #57795
Assignees
Labels
bug Confirmed user-visible misbehaviour in official release

Comments

@CurtizJ
Copy link
Member

CurtizJ commented Dec 8, 2023

SELECT maxMap([number % 3, (number % 4) - 1], [number, NULL])
FROM numbers(3)
GROUP BY number
    WITH TOTALS
ORDER BY number ASC;
┌─maxMap(array(modulo(number, 3), minus(modulo(number, 4), 1)), array(number, NULL))─┐
│ ([-1,0],[0,0])                                                                     │
│ ([0,1],[0,1])                                                                      │
│ ([1,2],[0,2])                                                                      │
└────────────────────────────────────────────────────────────────────────────────────┘

Totals:
┌─maxMap(array(modulo(number, 3), minus(modulo(number, 4), 1)), array(number, NULL))─┐
│ ([-1,0,1,2],[0,0,0,2])                                                             │
└────────────────────────────────────────────────────────────────────────────────────┘

We should have totals: [-1,0,1,2],[0,0,1,2] because we have value 1 for key 1 in the second row. This behaviour is reflected in test 02480_max_map_null_totals, but it's wrong.

However it works correctly with settings group_by_two_level_threshold = 1, max_bytes_before_external_group_by = 1:

SELECT maxMap([number % 3, (number % 4) - 1], [number, NULL])
FROM numbers(3)
GROUP BY number
    WITH TOTALS
ORDER BY number ASC
SETTINGS group_by_two_level_threshold = 1, max_bytes_before_external_group_by = 1;
┌─maxMap(array(modulo(number, 3), minus(modulo(number, 4), 1)), array(number, NULL))─┐
│ ([-1,0],[0,0])                                                                     │
│ ([0,1],[0,1])                                                                      │
│ ([1,2],[0,2])                                                                      │
└────────────────────────────────────────────────────────────────────────────────────┘

Totals:
┌─maxMap(array(modulo(number, 3), minus(modulo(number, 4), 1)), array(number, NULL))─┐
│ ([-1,0,1,2],[0,0,1,2])                                                             │
└────────────────────────────────────────────────────────────────────────────────────┘
@CurtizJ CurtizJ added the potential bug To be reviewed by developers and confirmed/rejected. label Dec 8, 2023
@CurtizJ CurtizJ changed the title Wrong value TOTALS in function maxMap Wrong value of TOTALS in function maxMap Dec 8, 2023
@CurtizJ CurtizJ added bug Confirmed user-visible misbehaviour in official release and removed potential bug To be reviewed by developers and confirmed/rejected. labels Dec 8, 2023
@CurtizJ CurtizJ self-assigned this Dec 12, 2023
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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant