Scenario 1: Executing a child Job - 6.3

Talend Open Studio for Big Data Components Reference Guide

EnrichVersion
6.3
EnrichProdName
Talend Open Studio for Big Data
task
Data Governance
Data Quality and Preparation
Design and Development
EnrichPlatform
Talend Studio

This scenario describes a two-component Job that calls another Job, which is the child Job, to display the content of files specified in the parent Job on the Run log console.

Creating the child Job

Dropping and linking components

  1. Drop a tFileInputDelimited and a tLogRow from the Palette to the design workspace.

  2. Connect the two components together using a Row > Main link.

Configuring the components

  1. Double-click tFileInputDelimited to open its Basic settings view and define its properties.

  2. Click in the File Name field and then press F5 to open the [New Context Parameter] dialog box and configure the context variable.

  3. In the Name field, enter a name for this new context variable, File in this example.

  4. In the Default value field, enter the full path to the default input file.

  5. Click Finish to validate the context parameter setup and fill the File Name field with the context variable.

    Note

    You can also create or edit a context parameter in the Context tab view beneath the design workspace. For more information, see Talend Studio User Guide.

  6. Click the [...] button next to Edit schema to open the [Schema] dialog box where you can configure the schema manually.

  7. In the dialog box, click the [+] button to add columns and name them according to the input file structure.

    In this example, this component will actually read files defined in the parent Job, and these files contain up to five columns. Therefore, add five string type columns and name them col_1, col_2, col_3, col_4, and col_5 respectively, and then click OK to validate the schema configuration and close the [Schema] dialog box.

  8. Double-click tLogRow to display its Basic settings view and define its properties.

  9. Select the Table option to view displayed content in table cells.

Creating the parent Job

Dropping and linking components

  1. Drop a tFileList and a tRunJob from the Palette to the design workspace.

  2. Connect the two components together using an Iterate link.

Configuring the components

  1. Double-click tFileList to open its Basic settings view and define its properties.

  2. In the Directory field, specify the path to the directory that holds the files to be processed, or click the [...] button next to the field to browse to the directory.

    In this example, the directory is called tRunJob and it holds three delimited files with up to five columns.

  3. In the FileList Type list, select Files.

  4. Check that the Use Glob Expressions as Filemask check box is selected, and then click the [+] button to add a line in the Files area and define a filter to match files. In this example, enter "*.csv" to retrieve all delimited files.

  5. Double-click tRunJob to display its Basic settings view and define its properties.

  6. Click the [...] button next to the Job field to open the [Find a Job] dialog box.

  7. Select the child Job you want to execute and click OK to close the dialog box. The name of the selected Job appears in the Job field.

  8. In the Context Param area, click the plus button to add a line and define the context parameter. The only context parameter defined in the child Job, named File, appears in the Parameter cell.

  9. Click in the Values cell, press Ctrl+Space on your keyboard to access the list of context variables, and select tFileList-1.CURRENT_FILEPATH.

    The corresponding context variable appears in the Values cell: ((String)globalMap.get("tFileList-1.CURRENT_FILEPATH")).

    Note

    For more information on context variables, see Talend Studio User Guide.

Executing the parent Job

  1. Press Ctrl+S to save your Job.

  2. Press F6 to execute the Job.

    The parent Job calls the child Job, which reads the files defined in the parent Job, and the content of the files is displayed on the Run console.

Related topic: tLoop, and Scenario 1: Buffering data of the tBufferOutput component.