Concepts → Internal Session Variable

About an internal session variable

An internal session variable is a tenant object that defines an internal query expression. An internal query expression typically queries a physical schema table or runtime business view. In this regard, the adjective “internal” references the physical schemas and business schemas within a given tenant.

When a user signs in to the Analytics Service, the Analytics Service — as a web application — creates a session (HttpSession in Apache Tomcat) for the user. A session maintains state information between requests for a particular user of a web application.

The first time the user invokes an internal session variable — usually by means of a calling expression such a formula expression — the Analytics Services creates an instance of the variable for the user, executes the internal query expression, and then assigns the query result as the variable value for the given user’s session. The value can be a scalar value of type String or an array of values of the type String. For the duration of the user’s session the variable value exist solely in the scope of the user session and is immutable.

You can use the Schema Manager to create and test an internal session variable. Using the Formula Builder, a schema developer or similar user can define an internal query expression.

You can reference an internal session variable in specific expression contexts such as a formula expression. You can assign access rights to an internal session variable.

Properties of an internal session variable

Here are the properties of an internal session variable.

Property Control Description
Name text box Enter the name of the internal session variable
Description text box Optional description of internal session variable.
Query Formula Builder Construct an internal query expression using the Formula Builder. The internal query expression result is the value of the internal session variable.

Example of the Query property for an internal session variable

Here is an example of an internal session variable that queries the value of the $yearAgo date system variable.

query(    
    formatDate(
      if(
        mod(year($yearAgo),4) = 0,
        addDays($yearAgo,-366),
        addDays($yearAgo,-365)
      ),
      "yyyy-MM-dd"
      )
)

In this example, the internal session variable stores the date as a string. Even though the formatDate() built-in function returns a scalar date, the internal session variable always store the value as a string.

Access rights for an internal session variable

A SuperUser (tenant administrator) or a user that belongs to a group assigned the SuperRole or the Schema Manager role can create, view, and edit the internal session variables in a given tenant.

Note: SuperUser and SuperRole access rights

Only a SuperUser (tenant administrator) or a user that belongs to a group assigned the SuperRole can view, edit, and share all session variables, regardless of ownership.

The following are the available access rights for an internal session variable:

Property Icon Description
Can View eye The user can View the internal session variable, for example, in the Formula Builder
Can Share node tree The user is able to Share the internal session variable with other users
Can Edit pen and paper The user is able to Edit he internal session variable

Test an internal session variable

If you have edit access rights to the internal session variable and belong to a group with the Schema Manager role, you can test the variable. There are two forms of testing a session variable:

Test: The result of the variable for the current user.

Test As: You can select a different user to test how the variable will display information for that user. This is useful when testing if permissions are configured properly or the output of the variable is dependent on the user.

Note

The result of a test on an internal session variable is independent of the current user’s session. As such, if the internal query expression’s source schema is updated during your session the test result will reflect the change. Your session’s captured value of the internal session variable will not express this update. You will need to sign out and start a new session to have your internal session variable value updated.

Steps to test an internal session variable

Here are the steps to test an internal session variable:

  • Sign in to the Incorta Direct Data Platform.
  • In the Navigation bar, select Schema.
  • In the Schema Manager, select the Session Variables tab.
  • In the list view, select an internal session variable.
  • In the Internal Variable dialog, select on of the following:

    • Select Test to view the result as the current user.
    • Select Test As, and then select a user to view the results as that user.
  • Select Cancel.

Additional considerations for an internal session variable

Here are some additional considerations for working with an internal session variable:

  • Conversion
  • Modifications
  • Owner of a scheduled job

Conversion

Regardless of the source data type, an internal session variable stores a scalar value as a string or array of scalar values as strings. When you use an internal session variable in a formula expression or filter expression, you may need to convert the string value to another data type using a built-in conversion function.

Modifications

If the owner or a user that belongs to a group with Edit access rights to the an internal session variable alters the query expression for the variable object and saves the modifications, the Analytics Service deletes the session variable for all other active users. For this reason, schema developers should be wary of altering internal session variables in production while not in maintenance window. When a user invokes the internal session variable again, the Analytics Services creates a new instance of the variable for the user.

Owner of scheduled job

The owner of a scheduled job for the email delivery of a dashboard defines the user session for the emailed dashboard. If the dashboard or dashboard insights contain references to an internal session variable, the value of the internal session variable is defined by the user session of the scheduled job owner.


© Incorta, Inc. All Rights Reserved.