tf_compute_dwell_times
Given a query input with entity keys (for example, user IP addresses) and timestamps (for example, page visit timestamps), and parameters specifying the minimum session time, the minimum number of session records, and the max inactive seconds, outputs all unique sessions found in the data with the duration of the session (dwell time).
Syntax
Input Arguments
Parameter | Description | Data Type |
---|---|---|
| Column containing keys/IDs used to identify the entities for which dwell/session times are to be computed. Examples include IP addresses of clients visiting a website, login IDs of database users, MMSIs of ships, and call signs of airplanes. | Column<TEXT ENCODING DICT | BIGINT> |
| Column containing keys/IDs of dwell “sites” or locations that entities visit. Examples include website pages, database session IDs, ports, airport names, or binned h3 hex IDs for geographic location. | Column<TEXT ENCODING DICT | BIGINT> |
| Column denoting the time at which an event occurred. | Column<TIMESTAMP(0|3|6|0)> |
| Constant integer value specifying the minimum number of seconds required between the first and last timestamp-ordered record for an entity_id at a site_id to constitute a valid session and compute and return an entity’s dwell time at a site. For example, if this variable is set to 3600 (one hour), but only 1800 seconds elapses between an entity’s first and last ordered timestamp records at a site, these records are not considered a valid session and a dwell time for that session is not calculated. | BIGINT (other integer types are automatically casted to BIGINT) |
| A constant integer value specifying the minimum number of successive observations (in | BIGINT (other integer types are automatically casted to BIGINT) |
| A constant integer value specifying the maximum time in seconds between two successive observations for an entity at a given site before the current session/dwell time is considered finished and a new session/dwell time is started. For example, if this variable is set to 86400 seconds (one day), and the time gap between two successive records for an entity id at a given site id is 86500 seconds, the session is considered ended at the first timestamp-ordered record, and a new session is started at the timestamp of the second record. | BIGINT (other integer types are automatically casted to BIGINT) |
Output Columns
Name | Description | Data Type |
---|---|---|
| The ID of the entity for the output dwell time, identical to the corresponding | Column<TEXT ENCODING DICT> | Column<BIGINT> (type is the same as the |
| The site ID for the output dwell time, identical to the corresponding | Column<TEXT ENCODING DICT> | Column<BIGINT> (type is the same as the |
| The site ID for the session preceding the current session, which might be a different | Column<TEXT ENCODING DICT> | Column<BIGINT> (type is the same as the |
| The site id for the session after the current session, which might be a different | Column<TEXT ENCODING DICT> | Column<BIGINT> (type will be the same as the |
| An auto-incrementing session ID specific/relative to the current | Column<INT> |
| The index of the nth timestamp ( | Column<INT> |
| The duration in seconds for the session. | Column<INT> |
| The number of records/observations constituting the current output row's session. | Column<INT> |
Example