The Talend Filter row or tFilterRow field will filter or restrict the input rows based on the given expression and return the output. We can use this Talend Filter Row field to get the sales higher than a particular value or return records of a specific city, state, or country, etc.
In this Talend Filter row example, we used the Customer table in our SQL Server database. The following screenshot shows the data inside that table.
Talend Filter Row Example
First, drag and drop the DBConnection, DBCommit, and DBInput to establish a connection to the SQL Server. Next, we selected the Customers table from the metadata.
Next, drag and drop the Talend tFilterRow from the palette to the job design. As you can see from the below tooltip, tFilterRow filters the input row by evaluating column conditions.
Please connect the DBInput main row to tFilterRow. Mostly, the input columns will sync with the tFilterRow. If that is not the case, then click on the Sync columns button.
Next, click the Edit Schema button to check or alter the tFIlterRow schema as per your requirements.
Within the Components tab, there are two options to perform the filters. One is Logical operators, and it has two options. By default, And is selected, but you can change it to Logical Or. It has nothing to do when we select only one column. However, if we choose two columns then the output rows have to satisfy both conditions.
The second one is the Conditions section – this is where we choose the column and perform the operation.
For now, we kept the default logical And, and then clicked on the Add (plus) button. By default, it adds the first column from the Customers table, i.e., EmpID. Please use the drop-down box to select the required column, and here, we chose the Occupation.
Under the Operators, we have the following options, such as Equals, Not Equal to, Greater than, Lower than (less than), Greater or Equal to (greater than or equal to), Lower or equal to ( less than or equal to). I don’t think I have to explain these options because you know what they do!
For the Talend Filter row demo purpose, we selected the Not Equal to the operator, and the value as a Skilled Manual. It means Talend tFilterRow has to return all the Customers whose Occupation is not equal to Skilled Manual.
Next, we are using the DBOutput to save the Talend tFilterRow output in a SQL Database. Here, we are creating the Talend_FilterRow table as the destination table.
Let us run the Talend Filter Row Job.
Let me open the Management studio to check the result. Remember, Talend tFilterRow is the same as the SQL Where Clause.
This time, we are using two fields and running the job. It means Talend tFilterRow has to return all the Customers whose Occupation is not equal to Skilled Manual and whose Yearly Income is greater than 50000.
Please check the Talend filter row result.
The tFilterRow component tab has an advanced option. Use this option to write a custom Java code to perform filters.
Let me change the Logical operator from And to Or. It means Talend Filter Row returns the Customers whose Occupation is equal to Management or YearlyIncome is greater than or equal to 60000.
Please check the Talend tFilterRow result.