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.
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.
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.
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.
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.
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.
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.
Please open the Management Studio and check the tUniqueRow output.
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.
You can see the Talend tUniqueRow output in SQL.