A context variable is a variable which is defined by the user for a particular context.
For creating contexts, you can either create context data sets on a one-shot basis from the context tab of a Job, 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.
You can define the values of your context variables when creating them. But, if the values are frequently subjected to change, then, modifying the values in the job every-time can become a tedious task, or an end user cannot open the application to change the parameters.
In such scenarios, the contexts parameters can be loaded dynamically either explicitly using the tContextLoad component or implicitly using the Implicit Context Load feature.
This blog describes how to fetch the context values from an external file and load them in the talend job explicitly.
tContextLoad can be used to load a context value from a flow.
Consider an example where the configuration of a PostgreSQL database is fetched from a file.
STEP1: Set up the context
In the context tab, add variables which will be loaded and required in the job.
STEP2: Configure input file
Drag tFileInputDelimited component into the canvas and set the properties of the component, to fetch the text file which holds the values to be loaded.
STEP3: Load context
By connecting tContextLoad component to the input file, the values from the flow will be loaded into contexts and can be fetched throughout the job.
STEP4: Connect to the main job
The main job which fetches data from a postgresql database and dumps values into a file is connected to context load subjob using OnSubjobOk trigger. Hence the configuration values from the file is loaded into the database using tContextLoad component.
In tPostgresqlInput component, set the configuration variables with the contexts as follows.
After executing the job, a file(output.txt) is created which holds values from the database table.
Changing the context values dynamically
After exporting the job, the values in the file holding the context values can be changed before execution. For this, copy the file and place it in the folder which holds .sh and .bat files.
The file path in the tFileInputDelimited has to be set to a relative path.
Export the job by clicking on the build job option of the job in the job design.
In the exported job folder which has .sh and .bat files place the file with context values.
Hence, the modifications in the values can be made in this file, if there are any changes required to be made in context values.
Best Open Source Business Intelligence Software Helical Insight is Here
A Business Intelligence Framework
If you have any queries please get us at firstname.lastname@example.org
Rajithacontext Parameters How do I load a context variable in Talend? How do you pass context parameters in Talend? Loading Context Parameters Dynamically From an External File PostgreSQL SQL talend Talend big data Using tContextLoad and Implicit Context Loading in Talend What are embedded context variables in Talend? What is context load in Talend?