Share this post and Earn Free Points!

Without knowledge what Talend context variables are and how to use them, you’ll never be able to take full advantage of this tool. And even if you workaround them, context variables would do the same a few times faster and simpler.

In this training:

  • I will explain what are context variables
  • I’ll tell you why you need them
  • and I’ll show you examples of how you can use them to make your work easier.



An ETL" (Extract, Transform, Load) job is a process used to extract data from one or more sources, transform it into a desired format or structure, and load it into a target destination, such as a data warehouse or database". ETL" jobs are commonly used in data integration scenarios to extract data from various sources, clean and transform it, and load it into a centralized repository for further analysis and reporting.

An ETL" job typically consists of three main phases:

  1. Extract: In this phase, the ETL" job retrieves data from one or more sources, such as databases, flat files", APIs, or streaming sources. The extracted data is typically stored in a staging area or intermediate storage, such as a temporary table or file.
  2. Transform: In this phase, the ETL" job applies various transformations to the extracted data, such as cleaning, filtering, aggregating, and enriching the data. The transformations are applied using a set of rules or logic, which can be defined using a programming" language or an ETL" tool.
  3. Load: In this phase, the ETL" job loads the transformed data into the target destination, such as a data warehouse or database". The load phase can also involve additional steps, such as data quality checks, indexing, and partitioning, to optimize the data for querying and analysis.

ETL Job Parametrization

ETL" (Extract, Transform, Load) job parametrization is the process of making an ETL" job configurable and flexible by using parameters or variables to control its behavior and functionality. This is typically done to enable an ETL" job to be reused or deployed in different environments or scenarios without requiring modification of the job itself.

There are several ways to parametrize an ETL" job, depending on the tools and technologies you are using. Some common approaches include:

  • Using context variables: Many ETL" tools, including Talend" Open" Studio and Apache Nifi, support the use of context variables to store and reference dynamic values within a job. Context variables can be used to pass input parameters to an ETL" job, and they can be set and changed at runtime.
  • Using command-line arguments: ETL jobs can be run from the command line" and can accept input arguments as command-line options. This allows you to pass input parameters to an ETL" job when you run it, and it can be a convenient way to run an ETL" job in a script or as part of a larger workflow.
  • Using a configuration file: An ETL" job can be configured to read input parameters from a configuration file, such as a properties file or an XML" file. This allows you to specify input values in a separate file, which can be easily changed and updated without modifying the ETL" job itself.

Talend Job Parametization

Talend" Open" Studio (TOS) has context variables that can store and reference dynamic values in a Talend" job.

Context Variable In Talend

These context variables are useful for customizing and configuring a Talend" job because they allow you to set values that can be changed at runtime without changing the job itself. Context variables can be defined at the project or job level and can be used in various ways within a Talend" job, such as passing values as input parameters, setting database connection details, configuring file paths, and storing intermediate values.

They can be created in TOS by using the context menu in the Repository tree view and referencing them within a Talend" job using the context.variable_name syntax.

Context variables can be defined at the project level or the job level, and they can be used in a variety of ways within a Talend" job. For example, you can use context variables to:

  • Pass values to a job as input parameters
  • Set database connection details or other configuration values
  • Configure file paths or other job-specific settings
  • Store and reference intermediate values within a job

Talend Context Variables

Context variables are primarily values ​​assigned under a certain name that can change during program or process operation. Imagine the situation that you created a process that loads data from a file into a database. So you had to include in the source component path to the file, its name, and file separator and the target component include username and password to database. These values ​​sometimes change, especially the password. What should you do then? Will you edit your process during each change? No, this is not feasible. This is where context variables are handy.

In Talend" Studio you can create individual context variables and context groups. You can use context groups in many ways, e.g. to:

  • isolation variables for DEV, TEST or PROD environments
  • grouping configuration of a specific database (server name, user" name, password, etc. in one group)
  • grouping of related variables, e.g. paths to configuration files.

Therefore, context variables allow you to use different variable values ​​in different environments, which allows you to quickly test the process in any environment you choose.

Talend DI Tutorial: Talend context variables
Talend" context variables

Adding Context Variables To The Process

Metadata as a group

For this training, I created a simple process that loads data from a file into a MySQL" database using record filtering in tFilterRow. As you can see in the screen below, the path to the file and its name is hardcoded, which in the case of changing the path or file name can exposes  errors and force editing the entire process.

Talend DI Tutorial: Talend context variables
Talend" context variables

There are two ways to add a context group:

  • Repository -> Contexts -> Create context group (unfortunately we would have to change the Property Type from Repository to Built-in later)
  • Editing the schema in Repository -> Metadata

The second way allows us to save the schema as a Repository, so we’ll use it in the instructions below.

To edit the metadata for the customer_data source, all you have to do is click on any field in the Component tab, e.g. File name / Stream. A pop-up will appear with the option of changing the settings to a buit-in or updating the connection. So click OK.

Talend DI Tutorial: Talend context variables
Talend" context variables

In step 3/3, select Export as context. A pop-up will appear in which we want to create a new context group. I called my group C_10_SRC_Customer.

Talend DI Tutorial: Talend context variables
Talend" context variables

Talend" Studio will automatically add values to the context group. To finish creating the group, select Finish. The studio will also ask about the propagation of changes in all processes which are using the source file – you should agree.

You should see your context group in the Contexts tab, and in the Component tab all file settings should be preceded by the word context, e.g. context.customer_data_File.

Single variables in context tab

There is a reason that tFilterRow is in the process, we will want to put a variable into the context tab which is used for filtering the data. To do this, add a new variable of type INT in the Context tab. My variable is called V_age_filter and has a value 30.

Talend DI Tutorial: Talend context variables
Talend" context variables

Now go to the Component tab and enter the name of your variable in the Value field, prefixing it with the word “context”.

BigData-ETL: Capture 10
Talend" context variables

Separation of environments using contexts

As I mentioned earlier, using context groups we can separate environments and run the same process in different environments with just one click. Talend" creates all the variables you create in the Default" environment. Let’s add a new environment called TEST.

To do this, in the Repository select Context -> <Your context group name> -> Edit context group. In step 2/2, select the green plus sign on the right side of the window.

Talend DI Tutorial: Talend context variables
Talend" context variables

Then add a new group by selecting New …, entering its name (TEST) and finally click OK. In the Context tab you can now see two groups: Default" and Test and change them for the duration of the process.

Talend DI Tutorial: Talend context variables
Talend" context variables


Overall, ETL" job parametrization is an important technique for making ETL" jobs more flexible, configurable, and maintainable, and it can help you streamline and automate your data integration and ETL" processes.

In Talend" Open" Studio (TOS), context variables are variables that can be used to store and reference dynamic values within a Talend" job. They are useful for parameterizing and configuring Talend" jobs, as they allow you to define values that can be changed at runtime without modifying the job itself.

Context variables are an important and powerful feature of TOS, and they can help you make your Talend" jobs more flexible, configurable, and maintainable.

Could You Please Share This Post? 
I appreciate It And Thank YOU! :)
Have A Nice Day!

How useful was this post?

Click on a star to rate it!

Average rating 4.8 / 5. Vote count: 69

No votes so far! Be the first to rate this post.

As you found this post useful...

Follow us on social media!

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?

Leave a Reply