Using contexts and variables - Cloud - 8.0

Talend Studio User Guide

Version
Cloud
8.0
Language
English
Product
Talend Big Data
Talend Big Data Platform
Talend Cloud
Talend Data Fabric
Talend Data Integration
Talend Data Management Platform
Talend Data Services Platform
Talend ESB
Talend MDM Platform
Talend Real-Time Big Data Platform
Module
Talend Studio
Content
Design and Development
Last publication date
2024-02-29
Warning: The UI of the context view and wizard for R2023-09 onwards is different from previous versions because of the user experience improvements. The related description and screenshots in this subsection, which are based on R2023-09, could be different for previous versions. For more information about these improvements, see New features in Talend Studio R2023-09 in Talend Release Notes.

Variables represent values which change throughout the execution of a program.

A global variable is a system variable which can be accessed by any module or function. It retains its value after the function or program using it has completed execution.

Warning: The implementation of the globalMap object is not synchronized by default. This may bring thread safety issues when you are using global variables created via the globalMap object in your Job. However, as the globalMap object is not shared among Jobs, if you are running multiple child Jobs in parallel, using the globalMap object inside each of the child Jobs can mitigate thread safety issues during parallelization. For more information about parallelization, see Using parallelization to optimize Job performance.

A context variable is a variable which is defined by the user for a particular context. Depending on the circumstances the Job or Route is being used in, you might want to manage it differently for various execution types, known as contexts (Prod and Test in the example given below). For instance, there might be various testing stages you want to perform and validate before a Job or Route is ready to go live for production use.

Note:

General advices for using context variables:

  • Use small pieces of data in context variables.
  • Avoid putting code in context variables.
  • Use appropriate variable types rather than the default type String, for example, the type Password for a password to enhance security, the type File or Directory for a file path or directory to avoid possible unwanted escaping.
  • Avoid using double quotes around a string value in general. However, double quotes must be used if
    • the string contains an escape character and you want the unescaping to happen.
    • the string has a leading or a trailing double quote that is part of the variable value.

A context is characterized by parameters. These parameters are mostly context-sensitive variables which will be added to the list of variables for reuse in the component-specific properties on the Component view through the Ctrl+Space keystrokes.

Talend Studio offers you the possibility to create multiple context data sets. Furthermore you can either create context data sets on a one-shot basis from the context tab of a Job or Route, or you can centralize the context data sets in the Contexts node of the Repository tree view in order to reuse them in different Jobs or Routes.

For a Job, you can define the values of your context variables when creating them, or load your context parameters dynamically, either explicitly using the tContextLoad component or implicitly using the Implicit Context Load feature, when your Jobs are executed.

Note: When loading context parameters dynamically, the parameter values will be loaded from the specified file or database and the parameter values statically defined in Talend Studio, or in Talend Management Console in the case of Talend Cloud context parameters, will not take effect.

This section describes how to create contexts and variables and define context parameter values.

For an example of loading context parameters dynamically using the tContextLoad component, see Context.

For an example of loading context parameters dynamically using the Implicit Context Load feature, see .