Scenario: Using tJavaRow to handle file content based on a dynamic schema - 6.1

Talend Components Reference Guide

Talend Big Data
Talend Big Data Platform
Talend Data Fabric
Talend Data Integration
Talend Data Management Platform
Talend Data Services Platform
Talend ESB
Talend MDM Platform
Talend Open Studio for Big Data
Talend Open Studio for Data Integration
Talend Open Studio for Data Quality
Talend Open Studio for ESB
Talend Open Studio for MDM
Talend Real-Time Big Data Platform
Talend Studio
Data Governance
Data Quality and Preparation
Design and Development

This scenario describes a three-component Job that uses Java code through a tJavaRow component to display the content of an input file and pass it to the output component. As all the components in this Job support the dynamic schema feature, we can leverage this feature to save the time of configuring each column of the schema.

Setting up the Job

  1. Drop tFileInputDelimited, tJavaRow, and tFileOutputDelimited from the Palette onto the design workspace, and label them according to their roles in the Job.

  2. Connect the components in a series using Row > Main links.

Configuring the input and output components

  1. Double-click the tFileInputDelimited component, which is labeled Source, to display its Basic settings view.


    The dynamic schema feature is only supported in Built-In mode and requires the input file to have a header row.

  2. In the File name/Stream field, type in the path to the input file in double quotation marks, or browse to the path by clicking the [...] button.

  3. In the Header field, type in 1 to define the first line of the file as the header.

  4. Click the [...] button next to Edit schema to open the [Schema] dialog box.

  5. Click the [+] button to add a column, give a name to the column, dyna in this example, and select Dynamic from the Type list. This dynamic column will retrieve the three columns, FirstName, LastName and Address, of the input file.

  6. Click OK to validate the setting and close the dialog box.

  7. Double-click the tFileOutputDelimited component, which is labeled Target, to display its Basic settings view.

  8. Define the output file path in the File Name field.

  9. Select the Include Header check box to include the header in the output file. Leave all the other settings are they are.

Configuring the tJavaRow component

  1. Double-click tJavaRow to display its Basic settings view and define the components properties.

  2. Click Sync columns to make sure that the schema is correctly retrieved from the preceding component.

  3. In the Code field, enter the following code to display the content of the input file and pass the data to the next component based on the defined dynamic schema column:

    output_row.dyna = input_row.dyna;


    In the Code field, input_row and output_row correspond to the links to and from tJavaRow.

Saving and executing the Job

  1. Press Ctrl+S to save your Job.

  2. Pressing F6, or click Run on the Run tab to execute the Job.

    The content of the input file is displayed on the console and written to the output file.