Talend Unique Row

The Talend Unique row or tUniqueRow field will remove duplicate rows or return distinct unique rows as an output. We can use this Talend Unique Row field if our source has duplicate content.

In this Talend Unique row example, we used the Customer table available in our SQL Server database. The following screenshot shows the data inside that table.

Customer Sales Table with HireDate

Talend Unique Row Example

First, drag and drop the DBConnection, DBCommit, and DBInput to establish a Talend connection to the SQL Server. Next, we selected the Customer table from the metadata.

Configure Server Connection and write table Select query

Next, drag and drop the Talend tUniqueRow from the palette to the job design. As you can see from the below tooltip, tUniqueRow makes a unique data flow based on the schema’s key set.

Add Talend tUniqueRow to the Workflow to get Unique Rows

Please connect the DBInput main row to tUniqueRow. Sometimes, the input columns will sync with the tUniqueRow. If that is not the case, then click on the Sync columns button.

Next, click the Edit Schema button to check or alter the schema as per your requirements.

Click the Edit Schema to check the Columns

Under the Components tab, there is a Unique Key section. It is the place where we specify the field or column to be unique by checking the Key attribute. And if you want to check Case Sensitive, then checkmark that option as well.

For the demonstration purpose, let me check the Education column as the Key attribute. It means the Talend Unique row will return the distinct Education columns from the Customers table.

Checkmark the Column in Talend tUniqueRow to the Workflow to get Unique Rows

Next, we are using the DBOutput to store or save the Talend tUniqueRow output in a SQL Database. As you can see, we are creating or using the Talend_tUniqueRow table as the destination table.

Configure the tDBOutput destination table

Let us run and see. From the below image, you can see, that Talend’s unique row field is passing only seven records from 15 records.

Run the Talend tUniqueRow Job to get Unique Education Rows

Please open the Management Studio and check the tUniqueRow output.

Distinct Education rows table

The Talend Unique Row field will not restrict you from selecting a single field as the key attribute. You can select as many key fields as you want. For instance, we select two columns Education and Occupation, and run the job. It means tUniqueRow returns distinct Education and Occupation.

Choose Multiple columns in Run the Talend tUniqueRow Component Tab to get Unique Rows

You can see the Talend tUniqueRow output in SQL.

Result table