Concepts → Global Variable

About a Global Variable

Unlike other objects in Incorta, a global variable is available to all tenant users. A global variable has a name, description, type, and value. A global variable is a static variable.

It is not possible for the value of a global variable to reference another variable, such as an external session variable, internal session variable, or another global variable for dynamic evaluation. It is possible, however, to edit the value of an existing global variable.

The Name of a global variable:

  • must be between 1 and 250 characters in length
  • must begin with an alpha character (lower or upper case) or an underscore (_)
  • after the first character, can contain zero or more alphanumeric characters in lower, upper, or mixed case
  • besides underscores (_), cannot contain special characters, symbols, or spaces
  • must be unique
  • is case-sensitive

The Type of a global variable is an Incorta data type:

  • date
  • double
  • integer
  • long
  • string
  • timestamp

The Value of a global variable must match the Type.

Supported global variable usage

Before the 5.2 release, the only supported usage of a global variable is in the predicate, the WHERE clause of a SQL query, for a table of the type SQL database as the data source. The usage supports both Query and Update Query configurations.

In this context, the syntax to reference a global variable is $$global_variable_name. In the example below, the $$gvar_TenantName has a string value of demo.

SELECT `ID`, `NAME`, `LOADMODE`, `PATH`, `DESCRIPTION`, `ENABLED`
FROM
`db_incorta_metadata`.`TENANT`
WHERE `NAME` = $$gvar_TenantName

Starting the 5.2 release, you can reference global variables in materialized views (MVs) when you use the Notebook Editor or the Query Builder to add or edit the MV script or incremental script using any supported language.

To reference a global variable, precede the variable name with double dollar sign, for example, $$gvar_name. When referencing string, date, and timestamp global variables, you must use single or double quotes depending upon the MV language. For Spark Scala, use double quotes, for other languages, use single quotes, for example '$$string_gvar_name'.

In the following example, the $$gvar_CustomerType has a string value of S, and the $$gvar_Quarter has an integer value of 3.

SELECT
$$gvar_Quarter As Quarter,
OnlineStore.customer.CustomerID,
OnlineStore.customer.CustomerType,
OnlineStore.customer.ModifiedDate
FROM
OnlineStore.customer
WHERE
OnlineStore.customer.CustomerType = '$$gvar_CustomerType'
Important

Global variables in MVs are evaluated when validating the MV script and when loading them. Thus, when you edit the value of a global variable, you must perform a full load of the related MVs.

Unsupported global variable usage

Although it may be possible to achieve, this release does not support the following usages of global variables:

  • Specify a global variable as a default value or assigned value for a presentation variable
  • Specify a global variable as a filter value for a dashboard runtime filter
  • Reference a global variable in an internal session variable and external session
  • Reference a global variable in a formula column for business schema view
  • Reference a global variable in a formula column for business schema Incorta Analyzer View
  • Reference a global variable in a formula column for an Incorta Analyzer Table
  • Reference a global variable in a runtime security filter for a table

With the Schema Manager, create and manage global variables

Only the tenant Super User, users that belong to a group assigned the SuperRole role, or users that belong to a group assigned the Schema Manager role, can create and manage global variables for a given tenant.

Create a global variable

To create a global variable, you use the Schema Manager

  • In the Navigation bar, select Schema.
  • In the Action bar, select + New → Global Variable.
  • In the Create Global Variable dialog, specify the following:
    • Name
    • Description
    • Type
    • Value
  • To save, select Create.
Date and timestamp global variable

When you create a global variable with a date or timestamp data type, you use a calendar date and time selection tool. In addition, when using the calendar date and time selection tool you may opt to select a date system variable for the global variable value.

Important

When you select a date system variable for a global variable value, you set a static value for the global variable which is simply a snapshot of the date system variable value.

Valid date system variables

If you create a global variable with a date data type, the following date system variables will be available for setting the global variable value:

  • $currentDate
  • $currentYearStart
  • $currentQuarterStart
  • $currentMonthStart
  • $currentMonthEnd
  • $currentWeekStart
  • $lastYearStart
  • $lastQuarterStart
  • $lastMonthStart
  • $lastWeekStart
  • $nextMonthStart
  • $dayAgo
  • $monthAgo
  • $quarterAgo
  • $weekAgo
  • $yearAgo
Valid timestamp system variables

If you create a global variable with a timestamp data type, the following date system variables will be available for setting the global variable value:

  • $currentTime
Search for a global variable

To search for a global variable, follow these steps:

  • In the Navigation bar, select Schema.
  • In the Context bar, select Global Variables.
  • In the Search bar text box, enter the search term.
Edit a global variable

Once defined, the value of the Name property of a global variable cannot be changed. You can, however, modify the property values for Description, Type, and Value. To edit a global variable, follow these steps:

  • In the Navigation bar, select Schema.
  • In the Context bar, select Global Variables.
  • In the List View, select the specific global variable row or in the right row gutter, select Edit (pen icon).
  • In the Edit Global Variable dialog, modify any or all of the following:
    • Description
    • Type
    • Value
  • To save, select Ok.
Delete one or more global variables

To delete one or more global variable, follow these steps:

  • In the Navigation bar, select Schema.
  • In the Context bar, select Global Variables.
  • In the List View, select the checkbox for each row for deletion.
  • In the Search bar, select Delete (trash icon).
  • In the Delete variable(s) dialog, select Delete.

To delete a single global variable, follow these steps:

  • In the Navigation bar, select Schema.
  • In the Context bar, select Global Variables.
  • In the List View, highlight the specific global variable row, and in the right row gutter, select Delete (trash icon).
  • In the Delete variable(s) dialog, select Delete.

Additional considerations

Note

If you have a session variable and a presentation variable with the same name, the global session variable will have a type of string and take precedence over any presentation variable you define in a dashboard.