Variable groups and global variables
Dataphin allows you to define global variables for values that you use frequently. Using global variables avoids the need to redefine them in each task, which simplifies long-term maintenance. Global variables also support permission control and code review to enhance security. This topic describes how to create variable groups and global variables.
Create a variable group
Variable groups help you organize variables for easier retrieval and management.
-
In the top navigation bar of the Dataphin homepage, choose Plan > Common Definitions.
-
On the Common Definitions page, click the Global Variables tab.
-
On the Global Variables tab, click Create Variable Group to open the Create Variable Group dialog box.
-
In the Create Variable Group dialog box, set the variable group name and variable group code as described in the following table.
Parameter
Description
Variable group name
A custom name for the variable group. The name must meet the following requirements:
-
Must be globally unique.
-
Cannot exceed 64 characters.
Variable group code
A unique, custom code for the variable group. The code must meet the following requirements:
-
Must be globally unique.
-
Can contain only digits, letters, and underscores (_).
-
Cannot exceed 64 characters.
-
-
Click OK to create the variable group.
Create a global variable
-
On the Global Variables tab, click Create Global Variable.
-
In the Create Global Variable dialog box, configure the parameters for the global variable.
Dataphin supports three variable types: general, date/time, and username/password. The configuration parameters vary by type and are described in the following sections.
General and username/password
Parameter
Description
Basic information
Variable name
A custom name for the variable. The name cannot exceed 64 characters.
Variable group
Defaults to the default variable group. You can select a different variable group from the drop-down list.
Code
A custom code used to reference the variable. It has a fixed prefix of dp_glb_. The code must meet the following requirements:
-
Must be globally unique.
-
Can contain only digits, letters, and underscores (_).
-
Cannot exceed 64 characters, including the dp_glb_ prefix.
NoteCodes are not case-sensitive. All uppercase letters are automatically converted to lowercase.
Permission control
If enabled, users must apply for permissions the first time they reference this global variable.
Code review
If enabled, you can specify reviewers who must approve any code submission that references this variable.
Description
A custom description for the global variable.
Variable value
Production and development environment isolation
-
Off: The same variable value is used in both the production and development environments.
-
On: You can set different values for the production and development environments. During debugging runs, the development value is used. Scheduled and manual runs in the production environment use the production value.
Variable value
Set the variable value for the production or development environment. The value is case-sensitive.
-
general: Cannot exceed 512 characters.
-
username/password: Cannot exceed 5,000 characters.
NoteWhen a task references a username/password global variable, its value is masked as
******in the runtime log. The data masking scope is as follows:-
In the task code, only the username/password variable reference is masked. Other text in the code that matches the variable's value, such as values from general variables or hard-coded strings, is not masked.
-
If the task code prints the variable's value to standard output, Dataphin scans the output and masks any text that matches the variable's value. This masking applies even if the matching text originates from other sources, such as general variables or hard-coded strings.
Date and time
Parameter
Description
Basic information
Variable name
A custom name for the variable. The name cannot exceed 64 characters.
Code
A custom code used to reference the variable. It has a fixed prefix of dp_glb_. The code must meet the following requirements:
-
Must be globally unique.
-
Can contain only digits, letters, and underscores (_).
-
Cannot exceed 64 characters, including the dp_glb_ prefix.
NoteCodes are not case-sensitive. All uppercase letters are automatically converted to lowercase.
Variable group
Defaults to the default variable group. You can select a different variable group from the drop-down list.
Permission control
If enabled, users must apply for permissions the first time they reference this global variable.
Code review
If enabled, you can specify reviewers who must approve any code submission that references this variable.
Description
A custom description for the global variable.
Variable value
Production and development environment isolation
-
Off: The same variable value is used in both the production and development environments.
-
On: You can set different values for the production and development environments. During debugging runs, the development value is used. Scheduled and manual runs in the production environment use the production value.
When base date type is set to business date (bizdate-year/month/day)
Applies to all tasks.
-
Variable output format: The output format for the calculated date/time variable. You can select one of the following formats from the drop-down list:
-
yyyyMMdd:
YearMonthDay. For example, 20220604. -
yyyy-MM-dd:
Year-Month-Day. For example, 2022-06-04. -
yyyy/MM/dd:
Year/Month/Day. For example, 2022/06/04. -
yyyyMMddHHmmss:
YearMonthDayHourMinuteSecond. For example, 20220604000000. -
yyyy-MM-dd HH:mm:ss:
Year-Month-Day Hour:Minute:Second. For example, 2022-06-04 00:00:00. -
unixtimestamp: The UNIX timestamp, which is the number of seconds that have elapsed since 00:00:00 UTC on January 1, 1970. For example, 2022-06-04 00:00:00 is converted to the UNIX timestamp 1654272000.
-
-
Quick date selection: Provides presets for common variable dates.
Selecting a quick date selection preset automatically populates the calculation logic in the Variable date field. You can also define the variable date manually.
-
Preview base date: The base date used for previewing the variable's value. This setting affects only the preview.
-
Variable date: Defines the variable's calculation logic. It takes the base date as input and applies offsets in Year, Quarter, Month, Week, or Day units.
If you add time offset, each calculation step uses the output from the previous step as its input.
After you set the variable date:
-
In the date preview, you can view the calculated date for the current step.
-
In the variable output format preview, you can view the calculated variable value for the current step, in your selected variable output format.
-
When base date type is set to business time (bizdatetime-year/month/day/hour/minute/second)
Applies only to tasks scheduled to run hourly or by the minute.
-
Variable output format: The output format for the calculated date/time variable. You can select one of the following formats from the drop-down list:
-
yyyyMMdd:
YearMonthDay. For example, 20220604. -
yyyy-MM-dd:
Year-Month-Day. For example, 2022-06-04. -
yyyy/MM/dd:
Year/Month/Day. For example, 2022/06/04. -
yyyyMMddHHmmss:
YearMonthDayHourMinuteSecond. For example, 20220604000000. -
yyyy-MM-dd HH:mm:ss:
Year-Month-Day Hour:Minute:Second. For example, 2022-06-04 00:00:00. -
unixtimestamp: The UNIX timestamp, which is the number of seconds that have elapsed since 00:00:00 UTC on January 1, 1970. For example, 2022-06-04 00:00:00 is converted to the UNIX timestamp 1654272000.
-
-
Quick date selection: Provides presets for common variable dates.
Selecting a quick date selection preset automatically populates the calculation logic in the Variable date field. You can also define the variable date manually.
-
Preview base time: The base time used for previewing the variable's value. This setting affects only the preview.
-
Variable date: Defines the variable's calculation logic. It takes the base date as input and applies offsets in Year, Quarter, Month, Week, or Day units.
If you add time offset, each calculation step uses the output from the previous step as its input.
After you set the variable date:
-
In the date preview, you can view the calculated date for the current step.
-
In the variable output format preview, you can view the calculated variable value for the current step, in your selected variable output format.
-
-
Quick time selection: Selecting a quick time selection preset automatically populates the calculation logic in the Variable time field. You can also define the variable time manually.
-
Variable time: Defines the variable's calculation logic. It takes the base date as input and applies offsets in Day, Hour, Minute, or Second units.
If you add time offset, each calculation step uses the output from the previous step as its input.
After you set the variable time:
-
In the time preview, you can view the calculated time for the current step.
-
In the variable output format preview, you can view the calculated variable value for the current step, in your selected variable output format.
-
-
-
Click OK to create the global variable.
Manage variable groups and global variables
Variable group operations
-
The default variable group cannot be edited or deleted.
-
You cannot edit or delete a variable group that contains variables.
|
Actions |
Description |
|
Edit |
Edits the name and code of a variable group.
|
|
Delete |
In the Action column (the last column in the variable group list) for the target variable group, click the Delete icon. |
Global variable operations
You cannot perform any actions on system variables.
|
Actions |
Description |
|
Search |
Enter a keyword in the search bar. The keyword is matched against the variable name, code, and value or calculation logic to filter the results. The values of username/password variables are not searchable. |
|
Edit |
In the Action column (the second-to-last column in the global variable list) for the target global variable, click the Edit icon to open the Edit Global Variable dialog box. Edit the parameters as needed. For parameter descriptions, see Create a global variable. Saving your changes generates a new version. Note
|
|
View dependencies |
Displays all submitted integration and computing tasks that reference the current global variable.
|
|
Delete |
Important
You can only delete global variables that have no dependencies. This action cannot be undone, so proceed with caution. In the Action column (the second-to-last column in the global variable list) for the target global variable, click the Delete icon. In the confirmation dialog box that appears, click OK to delete the variable. |
|
View history |
In the Action column (the second-to-last column in the global variable list) for the target global variable, click the View history icon. The version history dialog box displays a list of versions, including the Version, Submitter, Submission time, Value/calculation logic, and Description. You can click the version comparison or version rollback icon in the Action column for a specific version.
|
|
Apply for permissions |
In the Action column (the second-to-last column in the global variable list) for the target global variable, click the more icon and select Apply for permissions. In the Apply for Variable Permissions dialog box that appears, configure the parameters and submit the request. For details, see Apply for, renew, and release variable permissions. |