aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/tests/sql/suites/window/generic/session.sql
blob: 998f12e1ea416a4336159d5960ba243870bbb699 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/* syntax version 1 */
/* postgres can not */

SELECT
    user,
    ts,
    payload,
    AGGREGATE_LIST(ts) over w as ts_session,
    COUNT(1) over w as session_len,
FROM plato.Input
WINDOW w AS (
    PARTITION BY user, SessionWindow(ts, 10)
    ORDER BY ts
    ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING
)
ORDER BY user, payload;