Hi,does doris support the accumulate function which likes the 'runningAccumulate' function in clickhouse? And this function should support dau metric, like count(distinct) #32891
Unanswered
neytao
asked this question in
A - General / Q&A
Replies: 1 comment
-
|
It looks very like some window function, for example: SELECT
grouping,
item,
runningAccumulate(state, grouping) AS res
FROM
(
SELECT
toInt8(number / 4) AS grouping,
number AS item,
sumState(number) AS state
FROM numbers(15)
GROUP BY item
ORDER BY item ASC
);
┌─grouping─┬─item─┬─res─┐
│ 0 │ 0 │ 0 │
│ 0 │ 1 │ 1 │
│ 0 │ 2 │ 3 │
│ 0 │ 3 │ 6 │
│ 1 │ 4 │ 4 │
│ 1 │ 5 │ 9 │
│ 1 │ 6 │ 15 │
│ 1 │ 7 │ 22 │
│ 2 │ 8 │ 8 │
│ 2 │ 9 │ 17 │
│ 2 │ 10 │ 27 │
│ 2 │ 11 │ 38 │
│ 3 │ 12 │ 12 │
│ 3 │ 13 │ 25 │
│ 3 │ 14 │ 39 │
└──────────┴──────┴─────┘Here is the SQL for Doris below: SELECT
grouping,
item,
sum(state) over(partition by grouping order by item rows between unbounded preceding and current row) AS res
FROM (
SELECT
cast(number / 4 as int) AS grouping,
number AS item,
sum(number) AS state
FROM numbers('number'='15')
GROUP BY item
ORDER BY item ASC
) t;
+----------+------+------+
| grouping | item | res |
+----------+------+------+
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 0 | 2 | 3 |
| 0 | 3 | 6 |
| 1 | 4 | 4 |
| 1 | 5 | 9 |
| 1 | 6 | 15 |
| 1 | 7 | 22 |
| 2 | 8 | 8 |
| 2 | 9 | 17 |
| 2 | 10 | 27 |
| 2 | 11 | 38 |
| 3 | 12 | 12 |
| 3 | 13 | 25 |
| 3 | 14 | 39 |
+----------+------+------+ |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
does doris support the accumulate function which likes the 'runningAccumulate' function in clickhouse? And this function should support dau metric, like count(distinct)
https://clickhouse.com/docs/en/sql-reference/functions/other-functions#runningaccumulate
Beta Was this translation helpful? Give feedback.
All reactions