Dataphin enables the creation of global variables, streamlining task code by eliminating redundant definitions and reducing maintenance efforts. These global variables include permission controls and code review features, enhancing security. This topic describes how to create a variable group and a global variable.
Create a variable group
Variable groups organize variables for simplified management and retrieval.
On the top menu bar of the Dataphin homepage, select Planning > Common Business Logic.
On the Common Business Logic page, click the Global Variable tab.
Under the Global Variable tab, click Create Variable Group to open the Create Variable Group dialog box.
In the Create Variable Group dialog box, enter the Variable Group Name and Variable Group Code as detailed in the table below.
Parameter
Description
Variable Group Name
Customize the variable group name. The name must meet the following requirements:
Must be globally unique.
Cannot exceed 64 characters in length.
Variable Group Code
Customize the variable group code, which is used to verify the uniqueness of the variable group. The code must meet the following requirements:
Must be globally unique.
Can only contain numbers, letters, and underscores.
Cannot exceed 64 characters in length.
Click OK to complete the creation of the variable group.
Create a global variable
Under the Global Variable tab, click Create Global Variable.
In the Create Global Variable dialog box, configure the global variable parameters.
The system supports three variable types: Common Variable, Date And Time, and Account Password. Each type has different configuration requirements. The parameters for each variable type are described as follows:
Common variable and account password
Parameter
Description
Basic Information
Variable Name
Customize the variable name. Cannot exceed 64 characters.
Variable Group
The default is Default Variable Group. You can click the drop-down list to select other variable groups.
Code
Customize the code, which serves as the variable's reference name. It begins with the fixed prefix dp_glb. The code must meet the following requirements:
Must be globally unique.
Can only contain numbers, letters, and underscores (_).
Cannot exceed 64 characters in length (including the total length of dp_glb_).
NoteThe code is case-insensitive. Uppercase letters will be automatically converted to lowercase letters.
Permission Control
When enabled, permission must be requested the first time the created global variable is referenced.
Code Review
When enabled, you can designate a code reviewer. If this global variable is referenced in code, the code reviewer must approve the submission.
Description
Customize the description. This is the note information for the global variable.
Variable Value
Production And Development Environment Isolation
Disabled: The production and development environments use the same variable value.
Enabled: You can set different values for the production and development environments. The development value is used during debugging in the development environment. The production value is used during scheduled production runs and manual operations.
Variable Value
Set the variable value for the production or development environment. The value is case-sensitive.
Common Variable: Cannot exceed 512 characters.
Account Password: Cannot exceed 5000 characters.
Date and time
Parameter
Description
Basic Information
Variable Name
Customize the variable name. Cannot exceed 64 characters.
Code
Customize the code, which serves as the variable's reference name. It begins with the fixed prefix dp_glb. The code must meet the following requirements:
Must be globally unique.
Can only contain numbers, letters, and underscores (_).
Cannot exceed 64 characters in length (including the total length of dp_glb_).
NoteThe code is case-insensitive. Uppercase letters will be automatically converted to lowercase letters.
Variable Group
The default is Default Variable Group. You can click the drop-down list to select other variable groups.
Permission Control
When enabled, permission must be requested the first time the created global variable is referenced.
Code Review
When enabled, you can designate a code reviewer. If this global variable is referenced in code, the code reviewer must approve the submission.
Description
Customize the description. This is the note information for the global variable.
Variable Value
Production And Development Environment Isolation
Disabled: The production and development environments use the same variable value.
Enabled: You can set different values for the production and development environments. The development value is used during debugging in the development environment. The production value is used during scheduled production runs and manual operations.
Baseline Date Type is set to Data Timestamp (bizdate-yyyymmdd)
Applicable to all nodes.
Variable Output Format: The format of the result value after the date and time variable calculation. Click the drop-down list to select from the following formats:
yyyyMMdd:
YYYYMMDD. 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:
YYYYMMDDHHMMSS. For example, 20220604000000.yyyy-MM-dd HH:mm:ss:
year-month-day hour:minute:second. For example, 2022-06-04 00:00:00.unixtimestamp: UNIX timestamp, representing the number of seconds since January 1, 1970, 00:00:00. For example, 2022-06-04 00:00:00 converted to a UNIX timestamp is displayed as 1654272000.
Quick Date Selection: Commonly used variable dates.
After setting Quick Date Selection, the corresponding calculation logic is automatically populated in Variable Date. You can also customize the Variable Date settings.
Preview Baseline Date: The baseline date used when previewing the variable value, used only for previewing configuration effects.
Variable Date: Defines the calculation logic for the variable, using the baseline date as input and performing offsets in the dimensions of Year, Quarter, Month, Week, and Day.
If Add Offset Time is enabled, the input date for each row's calculation is the output date from the previous row's calculation.
After configuring Variable Date:
In Date Preview, you can view the date obtained from this row's calculation.
In Variable Output Format, you can view the variable value after this row's calculation, displayed according to your selected Variable Output Format.
Baseline Date Type is set to Business Time (bizdatetime-yyyymmddhhmmss)
Only used for nodes scheduled by hour or minute.
Variable Output Format: The format of the result value after the date and time variable calculation. Click the drop-down list to select from the following formats:
yyyyMMdd:
YYYYMMDD. 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:
YYYYMMDDHHMMSS. For example, 20220604000000.yyyy-MM-dd HH:mm:ss:
year-month-day hour:minute:second. For example, 2022-06-04 00:00:00.unixtimestamp: UNIX timestamp, representing the number of seconds since January 1, 1970, 00:00:00. For example, 2022-06-04 00:00:00 converted to a UNIX timestamp is displayed as 1654272000.
Quick Date Selection: Commonly used variable dates.
After setting Quick Date Selection, the corresponding calculation logic is automatically populated in Variable Date. You can also customize the Variable Date settings.
Preview Baseline Time: The baseline time used when previewing the variable value, used only for previewing configuration effects.
Variable Date: Defines the calculation logic for the variable, using the baseline date as input and performing offsets in the dimensions of Year, Quarter, Month, Week, and Day.
If Add Offset Time is enabled, the input date for each row's calculation is the output date from the previous row's calculation.
After configuring Variable Date:
In Date Preview, you can view the date obtained from this row's calculation.
In Variable Output Format, you can view the variable value after this row's calculation, displayed according to your selected Variable Output Format.
Quick Time Selection: After setting Quick Time Selection, the corresponding calculation logic is automatically populated in Variable Time. You can also customize the Variable Time settings.
Variable Time: Defines the calculation logic for the variable, using the baseline date as input and performing offsets in the dimensions of Day, Hour, Minute, and Second.
If Add Offset Time is enabled, the input date for each row's calculation is the output date from the previous row's calculation.
After configuring Variable Time:
In Time Preview, you can view the time obtained from this row's calculation.
In Variable Output Format, you can view the variable value after this row's calculation, displayed according to your selected Variable Output Format.
Click OK to complete the creation of the global variable.
Manage variable groups and global variables
Operations supported for variable groups
The Default Variable Group does not support edit or delete operations.
Variable groups that contain variables do not support edit or delete operations.
Operation | Description |
Edit | Edit the name and code of the variable group.
|
Delete | Click the Delete icon in the Actions column (the last column in the global variable list) of the target variable group to delete the current variable group. |
Operations supported for global variables
System variables do not support any operations.
Operation | Description |
Search | After you enter keywords in the search bar, the system automatically matches variable names, codes, and values/calculation logic (excluding values of account password type variables) and filters out relevant global variables. |
Edit | Click the Edit icon in the Actions column (the second-to-last column in the global variable list) of the target global variable to open the Edit Global Variable dialog box. In the dialog box, edit the relevant parameters. The parameter configuration is the same as that for creating a new global variable. For more information, see Create a global variable. After you complete the editing, a new version is generated. Note
|
View Dependencies | View all integration and computing nodes that reference the current global variable and have been submitted.
|
Delete | Important You can only delete global variables that have no dependencies. Deleted variables cannot be recovered. Please proceed with caution. Click the Delete icon in the Actions column (the second-to-last column in the global variable list) of the target global variable. In the dialog box that appears, click Confirm to complete the deletion. |
View Version History | Click the View Version History icon in the Actions column (the second-to-last column in the global variable list) of the target global variable. In the View Version History dialog box, you can view the version list, which includes Version Number, Submitted By, Submitted At, Value/Calculation Logic, and Description. You can click the Compare Versions or Roll Back Version icon in the Actions column of the target version to perform the corresponding operation.
|
Request Permission | Click the More icon in the Actions column (the second-to-last column in the global variable list) of the target global variable, and select Request Permission. You will be redirected to the Request Variable Permission dialog box. Fill in the relevant parameter configurations to complete the permission request. For more information, see Request, renew, and return variable permissions. |