Scenario: Merge the content of several rows using different columns as rank values - 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
task
Data Governance
Data Quality and Preparation
Design and Development
EnrichPlatform
Talend Studio

This scenario describes a three-component Job that uses the tSurviveFields component to merge, based on different rank values, the content of data rows in different columns and then writes the result in an output file.

In this scenario, we have already stored the input schemas of the input file in the Repository. For further information about storing schema metadata in the Repository, see Talend Studio User Guide.

The input file contains four columns: grp, gender, firstname and count. The data in the input file has problems such as duplication, first names spelled differently or wrongly and different information for the same customer.

Setting up the Job

  1. In the Repository tree view, expand Metadata and the FileExcel node where you have stored the input schemas and then drop it onto the design workspace.

    The tFileInputExcel component which contains your schema displays on the workspace.

  2. Drop a tSurviveFields and a tFileOutputExcel component from the Palette onto the design workspace.

  3. Link the components together using Row > Main connections.

Configuring the components

  1. Double-click tFileInputExcel to display its Basic settings view.

    All tFileInputExcel property fields are automatically filled in. If you did not define your input schemas locally in the Repository, fill in the details manually after selecting Built-in in the Schema and Property Type fields.

  2. Double-click tSurviveFields to display its Basic settings view and define the component properties.

  3. Click Sync columns to retrieve the schema from the preceding component. You can click the [...] next to Edit schema to view the schema.

  4. In the Key area, click the [+] button to add a new line, and click the field and select the name of the column you want to use to merge the data from the list.

    You can select multiple columns as an aggregation set if you want to merge data based on multiple criteria. For this scenario, we want to use the grp column to merge the data.

  5. In the Operations area, click the [+] button to add new rows. Here you can define the output columns that will hold the results of the merge operation. In this scenario, we want to merge the data in the firstname, gender and count columns.

  6. Click in the first field of the Output column and select the first output column that will hold the merge results.

    • Click in the first field of the Function column and select the merge operation you want to perform.

    • Click in the first field of the Input Column list and select the column from which the input values are to be taken.

    • Click in the first field of the Rank column and select the column that will be used as a basis for the merge operation.

    • Repeat the same process to define the parameters for the merge operation for all the columns you want to write in the output file.

      Here we want to read data from the firstname and gender input columns and write only the values with the maximum rank (row count) in firstname and gender output columns. We also want to read data from the count input column and write its maximum value in a count output column.

  7. Double-click the tFileOutputExcel component to open its Basic settings view.

  8. Specify the path to the target file, select the Include header check box, and leave the other settings as they are.

Executing the Job

  • Save your Job and press F6 to execute it.

    A progress bar displays to show the percentage of the merge operation completed. When the percentage progress bar reaches 100%, the specified data is regrouped and written in the defined output columns.

    The figure below illustrates a sample of the output data after the merge operation.