Commit 2a9a713
committed
Rolling window queries
CubeStore extension to implement rolling window measures in CubeJS.
Tests are in the CubeStore repository.
The syntax is of the form:
```
SELECT dim, key1, key2, other,
ROLLING(SUM(x) RANGE BETWEEN 7 PRECEDING AND UNBOUNDED FOLLOWING)
ROLLING(AVG(x) RANGE BETWEEN 7 PRECEDING AND UNBOUNDED FOLLOWING)
FROM input
ROLLING_WINDOW
DIMENSION dim
PARTITION BY key1, key2
FROM 0 to 10 EVERY 2
```
Semantics are roughly:
- compute rolling window aggregations over input data,
- window "rolls over" the `DIMENSION` column, only values defined in
the range by `FROM .. TO .. EVERY ..` are reported,
- each "group" defined by columns in `PARTITION BY` is handled
and reported independently,
Current limitations:
- only integer ranges (timestamps and intervals are coming),
- only ranges with up to 10M points are supported to avoid infinite
loops are accidental DOS. This is still a fairly large limit and
can lead to DOS given enough input data.1 parent 7b44028 commit 2a9a713
13 files changed
Lines changed: 954 additions & 58 deletions
File tree
- datafusion
- src
- cube_ext
- logical_plan
- optimizer
- physical_plan
- sql
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | | - | |
| 51 | + | |
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
0 commit comments