Talend Parent Child Job

This section covers the steps to create a Talend Parent Child job with an example. It also helps you understand how we can pass values from Talend parent job to child job using context variables. When we want to use the child job ETL in Talend parent job, we can use tRunJob.

Talend Parent Child Job Example

To demonstrate the Talend Parent Child Job, we use the below Emp Information text file.

Text File 0

Create a Talend Child Job

First, we created a child job and named it as the Child_Job. Next, we used the Talend tJava component to print a simple message.

Talend Parent Child Job 1

The above text file has five columns, and we want to print all the column values except the Emp ID using the child job.

In general, we don’t get the values from parent job to child job. To provide the same, we need context variables. Let me add four contexts within this the child job to accommodate those text file columns.

Context Tab to View Columns 2

Within the tJava components tab, we added the following Java code.

System.out.println(
StringHandling.UPCASE(context.FirstName + " " + context.LastName) +
" Working as a " + context.Occupation + " earning " + context.YearlyIncome + " Monthly!"
);
Code for tJava 3

The above code will concat first name and last name. Then the UPCASE function converts the name to uppercase.

Create a Talend Parent Job

As you can see, we created another job called Parent_Job and added the tFileInputDelimited to load text file data into Talend.

Talend Parent Child Job 4

We selected the File name using the browse button and changed the Filed separator to a comma.

File Input Delimiter 5

Please click on the Edit Schema and add the Column names and the length.

Talend Parent Child Job 6

Next, we added the tFlowToIterate to iterate the rows in a text file, and then, added the tRunJob. It means for each row in the text file, the tFlowToIterate helps to iterate tRunjob and displays the print statement.

Talend Parent Child Job 7

Within the tRunJob Component tab, we have selected Child_Job.

Talend Parent Child Job 8

Within the Context Param, use the add button to add the child job’s context param, i.e., FirstName. If you don’t have any context variables, then we can’t pass any values from the Parent job to child job.

Talend Parent Child Job 9

Next, we assigned the FirstName of the Main row to this context parameter.

Talend Parent Child Job 10

Similarly, assign the values for the remaining context parameters.

Talend Parent Child Job 11

Once hit the run button of this Talend Parent Child Job, you can see the result. If you see the execution flow, tRunJob has executed ten times because there are ten rows in the Employee table.

Talend Parent Child Job 12