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 the parent job to the child job using context variables. When we want to use the child job ETL in the 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.

Employee Information File

Create a Talend Child Job

First, we created a child job and named it 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 child job to accommodate those text file columns.

Create four fields in Context Tab to Map Columns

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!"
);
Write a Code for tJava

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. Please click on the Edit Schema and add the Column names and the length.

Edit Schema

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.

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 the child job.

Talend Parent Child Job 9

Next, we assigned the FirstName of the Main row to this context parameter. Similarly, assign the values for the remaining context parameters.

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.

Run the Talend Parent Child Job Workflow