Teradata R Package Function Reference - 16.20 - Sessionize - Teradata R Package

Teradata® R Package Function Reference

prodname
Teradata R Package
vrm_release
16.20
created_date
February 2020
category
Programming Reference
featnum
B700-4007-098K

Description

The Sessionize function maps each click in a session to a unique session identifier. A session is defined as a sequence of clicks by one user that are separated by at most n seconds.

Usage

  td_sessionize_sqle (
      data = NULL,
      time.column = NULL,
      time.out = NULL,
      click.lag = NULL,
      emit.null = FALSE,
      data.partition.column = NULL,
      data.order.column = NULL
  )

Arguments

data

Required Argument.
Specifies the name of the input table.

data.partition.column

Partition By columns for data.
Values to this argument can be provided as a list, if multiple columns are used for ordering.

data.order.column

Order By columns for data.
Values to this argument can be provided as a list, if multiple columns are used for ordering.

time.column

Required Argument. Specifies the name of the input column that contains the click times.
Note: The time.column must also be an data.order.column.

time.out

Required Argument.
Specifies the number of seconds at which the session times out. If session_timeout seconds elapse after a click, then the next click starts a new session. The data type of time.out is DOUBLE PRECISION.

click.lag

Optional Argument.
Specifies the minimum number of seconds between clicks for the session user to be considered human. If clicks are more frequent, indicating that the user is a "bot," the function ignores the session. The min_human_click_lag must be less than session_timout. The data type of min_human_click_lag is DOUBLE PRECISION.

emit.null

Optional Argument.
Specifies whether to output rows that have NULL values in their session id and rapid fire columns, even if their time.column has a NULL value.
Default Value: FALSE

Value

Function returns an object of class "td_sessionize_sqle" which is a named list containing Teradata tbl object.
Named list member can be referenced directly with the "$" operator using name: result

Examples

    # Get the current context/connection
    con <- td_get_context()$connection
    
    # Load example data.
    loadExampleData("sessionize_example", "sessionize_table")
    
    # Create remote tibble objects.
    sessionize_table <- tbl(con, "sessionize_table")
    
    # Example 1 -
    td_sessionize_out <- td_sessionize_sqle(data = sessionize_table,
                            data.partition.column = c("partition_id"),
                            data.order.column = c("clicktime"),
                            time.column = "clicktime",
                            time.out = 60,
                            click.lag = 0.2
                            )