The Talend Replicate or tReplicate field is to replicate or duplicate the input source data into multiple copies. So that we can perform different operations on each copy. For instance, if we have the sales data by country, you can make a copy perform aggregations on one copy, and apply filters on the other copy.
In this example, we use this Talend Replicate transformation to create two copies of the source table and perform string replace and aggregate the numeric values.
Talend Replicate Example
To demonstrate the same, we are using the customers table in our SQL Database. From the below Talend screenshot, you can see the connection details and the table that I was using. I suggest you refer to Connect Talend to the SQL article to understand these settings.
Next, drag and drop the Talend tReplicate field from the pallet to the design window to replicate the Data.
Please connect the DBInput main row to the Talend replicate field. As you can see from the below image, there is nothing much you can do in the replicate component tab.
Click on the Edit schema button will open the following window. Here, you can check the input and output fields, and change them as per your requirements. For us, it was perfect, so we kept it as it was and clicked the ok button.
Next, we added the tReplace filed and connected the tReplicate main output to the replace filed. Next, we replace the Education with Btech and Occupation column value Management with Admin. Please refer Talend Replace article to understand this.
When you right-click on the Talend replicate field, it again shows the Main row option, which is not possible with any other field. Because all the fields have one Main row and replicate is for duplicating data or making copies.
Here, we attached the Main row to tAggregateRow field, which will perform aggregations. As you see below, we are grouping the Customers by Education and occupation, and finding the Sum of yearly Income and sales. Please refer Talend Aggregate article.
Next, we used two tDBOutput fields connected with the SQL database. For the data replacement, we are creating a new table Replciate_Replace.
For the aggregated data, we are creating a new table Replciate_AggregateRow.
Let us run the Talend tReplicate to Replicate the Data and see.
From the above screenshot, you can see, the tReplicate is passing 15 rows to both the Replace and tAggregateRow fields, which means it is making a fresh copy of customers. Within the SQL Server, let us see the Replace data.
The aggregated data is