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 resIf 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)] │
└─────────────┴─────────────┴─────────────────────────────────┘ |
There was a problem hiding this comment.
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.
This is wrong. If constructor has thrown an exception, destructor must not be called.
alexey-milovidov
left a comment
There was a problem hiding this comment.
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
arrayReduceInRangeswhich aggregates array elements in given ranges.Detailed description / Documentation draft: