Scenario 2: Aggregating values based on dynamic schema - 6.1

Talend Components Reference Guide

EnrichVersion
6.1
EnrichProdName
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
EnrichPlatform
Talend Studio
task
Data Governance
Data Quality and Preparation
Design and Development

In this scenario, a four-component Java Job uses a tAggregateRow component to read data from a CSV file, group the data, and then send the grouping result to the Run console and an output file. A dynamic schema is used in this Job. For more information about dynamic schema, see Talend Studio User Guide.

  • Drop the components required for this use case: tFileInputDelimited, tAggregateRow, tLogRow and tFileOutputDelimited from the Palette to the design workspace.

  • Connect these components together using Row > Main links.

  • Double-click the tFileInputDelimited component to display its Basic settings view.

Warning

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

  • Select Built-In from the Property Type list.

  • Click the [...] button next to the File Name field to browse to your input file. In this use case, we use a simple CSV file that has only three columns, as shown below:

  • Specify the header row in Header field. In this use case the first row is the header row.

  • Select Built-In from the Schema list, and click Edit schema to set the input schema.

Warning

The dynamic column must be defined in the last row of the schema.

  • In the schema editor, add two columns and name them Task and Other respectively. Set the data type of the Other column to Dynamic to retrieve all the columns undefined in the schema.

  • Click OK to close the schema editor.

  • Double-click the tAggregateRow component to display the Basic settings view.

  • Click Sync columns to reuse the input schema for the output row. If needed, click Edit schema and rename the columns in the output schema. In this use case, we simply keep the schema as it is.

  • Add a row in the Group by table by clicking the plus button, and select Other in both Output column and Input column position fields to group the data entries by the dynamic column.

Warning

Dynamic column aggregation can be carried out only for the grouping operation.

  • Add a row in the Operations table by clicking the plus button, select Task in both Output column and Input column position fields, and select list in the Function field so that all the entries of the Task column are listed in the grouping result.

  • To view the output in the form of a table on the Run console, double-click the tLogRow component and select the Table option in the Basic settings view.

  • Double-click the tFileOutputDelimited component to display its Basic settings view.

  • Click the [...] button next to the File Name field to browse to the directory where you want to save the output file, and then enter a name for the file.

  • Select the Include Header check box to retrieve the column names as well as the grouped data.

  • Save your Job and press F6 to run it.

    As shown in the Job execution result, the data entries are grouped as per Team and Status.