This Java scenario describes a four-component Job where the tConvertType component is used to convert Java types in three columns, and a tMap is used to adapt the schema and have as an output the first of the three columns and the sum of the two others after conversion.
In this scenario, the input schemas for the input delimited file are stored in the repository, you can simply drag and drop the relevant file node from Repository - Metadata - File delimited onto the design workspace to automatically retrieve the tFileInputDelimited component's setting. For more information, see Talend Studio User Guide.
Drop the following components from the Palette onto the design workspace: tConvertType, tMap, and tLogRow.
In the Repository tree view, expand Metadata and from File delimited drag the relevant node, JavaTypes in this scenario, to the design workspace.
The [Components] dialog box displays.
From the component list, select tFileInputDelimited and click Ok.
A tFileInputComponent called Java types displays in the design workspace.
Connect the components using Row > Main links.
Double-click tFileInputDelimited to enter its Basic settings view.
Set Property Type to Repository since the file details are stored in the repository. The fields to follow are pre-defined using the fetched data.
The input file used in this scenario is called input. It is a text file that holds string, integer, and float java types.
Fill in all other fields as needed. For more information, see tFileInputDelimited. In this scenario, the header and the footer are not set and there is no limit for the number of processed rows.
Click Edit schema to describe the data structure of this input file. In this scenario, the schema is made of three columns, StringtoInteger, IntegerField, and FloatToInteger.
Click Ok to close the dialog box.
Double-click tConvertType to enter its Basic settings view.
Set Schema Type to Built in, and click Sync columns to automatically retrieve the columns from the tFileInputDelimited component.
Click Edit schema to describe manually the data structure of this processing component.
In this scenario, we want to convert a string type data into an integer type and a float type data into an integer type.
Click OK to close the [Schema of tConvertType] dialog box.
Double-click tMap to open the Map editor.
The Map editor displays the input metadata of the tFileInputDelimited component
In the Schema editor panel of the Map editor, click the plus button of the output table to add two rows and name them to StringToInteger and Sum.
In the Map editor, drag the StringToInteger row from the input table to the StringToInteger row in the output table.
In the Map editor, drag each of the IntegerField and the FloatToInteger rows from the input table to the Sum row in the output table and click OK to close the Map editor.
In the design workspace, select tLogRow and click the Component tab to define its basic settings. For more information, see tLogRow.
Press Ctrl+S to save the Job.
Press F6 to execute it.
The string type data is converted into an integer type and displayed in the StringToInteger column on the console. The float type data is converted into an integer and added to the IntegerField value to give the addition result in the Sum column on the console.