Talend Tutorial9 Using Context Variables

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Talend

Tutorial Task Aid >


Using Context Variables

This tutorial uses Talend Open Studio Data Integration version 6

1. Create a repository context group


a. In the Project Repository, right-click Contexts > Create context group. In the Name field of
the Create / Edit a context group wizard, type databasePropertyType, and click Next.
b. To add variables to the context group, click the [+] button five times and type the field
names as host, port, database, username, and password.
c. To change the Type for the password field, click the field and click Password.
d. In the Default Values column, assign values for each variable based on your server and
click Finish.
The new context group, databasePropertyType 0.1, is displayed under Contexts in the Project
Repository. To use this context group, you will need to import it into the Job.

2. Use the context variables in the Job by importing the group


a. To display all the context groups in the Project Repository, in the Contexts view, click the
Import Context button next to the [] button.
b. To select all the variables, in the Select Context Variables window that appears, select
Context: databasePropertyType.
Alternative method: You can expand the context group and select only a few variables.
The variables are imported into the Job along with their values. Note that you cannot change
the values because they belong to the context group in the repository.
c. The imported variables can be accessed in the Job by using the prefix "context." plus the
variable name. In the Component view of the MySql component, replace the fixed values
from the configuration with the corresponding variable from the context group.
Note: While changing these fields, you can summon the auto-completion window by typing
the first letters of the word, and then pressing the Ctrl + Space keys.
d. To run the Job, in the Run view, click Run.
The Job is run using the variables and default values defined in the context group.

Talend takes the complexity out of integration


Based on open source Scalable Future-proof Predictable cost
Visit www.talend.com Follow us on Twitter @Talend
Talend Tutorial Task Aid >

3. Add more contexts to the Job


a. In the Project Repository, right-click databasePropertyType 0.1 > Edit context group.
b. In the Create/Edit a context group wizard, click Next.
c. To create and configure a new context, click on the [+] button next to right of the Default
column. In the Configure Contexts window that appears, click New and type production as
its name.
d. Similarly, add another context called test.
Two new contexts, with the default context values, are created.
e. To change the values for the production and test contexts, click in each field and enter the
new value. Click Finish.
f. To propagate the modifications to the Job, in the Modification dialogue box that appears,
click Yes.
g. In the Update Detection window, ensure that the new contexts have been selected and
click OK.
h. To view the two new contexts added to the group, in the Contexts view of the Job, scroll
to the right.
i. To run the Job, in the Run view, click the context and then click Run.

4. Use the context variables in a metadata definition


a. To replace the fixed property values of the metadata with context variables, in the Project
Repository, right-click the movies 0.1 metadata, and then click Edit file delimited.
b. To export the default values as a context, in the Edit an existing Delimited File wizard,
navigate to the third step, and click Export as context.
c. In the Create / Reuse a context group window, ensure that Create a new repository
context is selected, and click Next.
d. In the Name field, type moviesContextGroup and click Next.
Observe that all the parameters have been changed to variables with the default values.
e. Close the Create/Reuse a context group window and the Edit an existing Delimited File
wizard.
f. To propagate the modifications to the Job, in the Modification dialogue box that appears,
click Yes.
g. In the Update Detection window, ensure that the new contexts have been selected, and
click OK.
In the component view of the movies component, observe that all the default property values
have been replaced by context variables. Also, under Contexts in the Project Repository,
observe that a new context group, moviesContextGroup 0.1 is displayed.

Talend takes the complexity out of integration


Based on open source Scalable Future-proof Predictable cost
Visit www.talend.com Follow us on Twitter @Talend

You might also like