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
Add function arrayReduceInRanges #9598
Conversation
The example is a bit misleading, as I interpret it as supplying two ranges : |
This one might be better. SELECT arrayReduceInRanges(
'sum',
[1, 2, 3, 4],
[5, 3, 4, 4],
[1000000, 200000, 30000, 4000, 500, 60, 7]
) AS res
|
Will it be more clear if you use array of tuples? SELECT arrayReduceInRanges(
'sum',
[(1, 5), (2, 3), (3, 4), (4, 4)],
[1000000, 200000, 30000, 4000, 500, 60, 7]
) AS res If you have a case, when index and length are in separate columns you can just use arrayZip SELECT
[1, 2, 3, 4, 5] AS x,
[1, 2, 3, 4, 5] AS y,
arrayZip(x, y) AS z
┌─x───────────┬─y───────────┬─z───────────────────────────────┐
│ [1,2,3,4,5] │ [1,2,3,4,5] │ [(1,1),(2,2),(3,3),(4,4),(5,5)] │
└─────────────┴─────────────┴─────────────────────────────────┘ |
│ [1234500,234500,34560,4567] │ | ||
└─────────────────────────────┘ | ||
``` | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is better to explicitly describe parameters.
By the way there is a function doc template:
https://github.com/ClickHouse/ClickHouse/blob/master/docs/dscr-templates/template-function.md
Sorry, it looks like this PR was not merged with upstream properly. Could you please rebase your commits? |
} | ||
catch (...) | ||
{ | ||
agg_func.destroy(place); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is wrong. If constructor has thrown an exception, destructor must not be called.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will merge to read the algorithm more carefully (it's difficult to understand).
I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=en
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Add function
arrayReduceInRanges
which aggregates array elements in given ranges.Detailed description / Documentation draft: