The Talend Sample Row or tSampleRow takes an input, selects the range of rows from it, and returns an output.
In this Talend Sample Row example, we are using the DimCurrency table available in the SQL AdventureWorks DW database.
Talend Sample Row Example
First, we established a connection to SQL Server. Next, used the DBInput to select the DimCurrency table within a database.
Drag and drop the sample row field from palatte to job design window.
Within the Talend tSampleRow Component tab, you can see the Range with examples. Let me explain those examples.
- “1, 5” – It returns lines 1 and 5 from the input (DimCurrency table).
- “10..20” – It only returns records or rows from line 10 to 20.
- “23..45, 48, 50..54” – It returns records from 23 to 45, 48th record, and rows from 50 to 54.
The Talend Sample row has an example range value “1, 5, 10..20”. It means the tSampleRow will select 1st row, 5th row, and rows from 10 to 20. For now, we leave these default range values.
Before we perform any action, let me show you the Schema by clicking the Edit Schema button. Change the records as per your need, and for me no need to change anything.
Next, drag-and-drop the DBOutput field and use the existing connection. As you can see, we are using Talend_SampleRow table as the destination. This Talend Sample row job will create the table if it doesn’t exist. Otherwise, it will drop the existing and creates a new table.
Let us run the Talend tSampleRow job.
Let me open Management Studio. From the below query, you can see the records 1, 5, and from 10 to 20.
For the demonstration purpose, we changed the default range value as “4..8, 15, 25, 50, 75, 90..93, 102..105”. It means rows from 4 to 8, line 15, line 25, line 50, line 75, lines from 90 to 93, and records from 102 to 105.
You can check the same from the below image.