DYNAMIC_SESSIONS
Collects an array of start and end times of sessions.
A session is defined as a group of events that are not separated by a gap of more than the configured WINDOWSIZE
.
Syntax
DYNAMIC_SESSIONS([MAX SESSIONS, ]TIME, WINDOWSIZE)
Arguments
MAX SESSIONS:
The maximum number of entries that can be counted (default: 2,147,483,647).
When MAX SESSIONS
is omitted, the limit is simply set to the default value.
TIME:
The time value associated with this event. This is the value that is used to
calculate the gap.
WINDOWSIZE:
The window gap size to use. This value should be in the same time unit as
TIME
.
Returns
An integer
Example
Data
[
{
"userId":1,
"time":1628894700000,
"level":1,
"event":"passed"
},
{
"userId":1,
"time":1628894760000,
"level":2,
"event":"passed"
},
{
"userId":1,
"time":1628894820000,
"level":3,
"event":"lost"
},
{
"userId":1,
"time":1628895000000,
"level":3,
"event":"passed"
},
{
"userId":1,
"time":1628895060000,
"level":4,
"event":"passed"
}
]
Query:
After collecting data about users who reach a mobile game level, you may want to get some information about their gaming sessions:
SELECT
data.userId AS userid:BIGINT,
DYNAMIC_SESSIONS(data.time, 60000) AS dynamic_sessions_data_time__60
FROM
"SESSION_DATA"
GROUP BY
Results:
{
"userid":1,
"dynamic_sessions_data_time__60":[
{
"endTime":1628894820000,
"startTime":1628894700000
},
{
"endTime":1628895060000,
"startTime":1628895000000
}
]
}
Related Functions
Dialog
Last updated
Was this helpful?