Talend Filter Rows

The Talend Filter row or tFilterRow field will filter or restrict the input rows based on the given expression and returns the output. We can use this Talend Filter Row field to get the sales higher than a particular value, or returning 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 Rows 1

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.

Talend Filter Rows 2

Next, drag and drop the Talend tFilterRow from palette to job design. As you can see from the below tooltip, tFilterRow filters input row by evaluating column conditions.

Talend Filter Rows 3

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

Talend Filter Rows 4

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

Talend Filter Rows 5

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 to Logical Or. It has nothing to do when we select only one column. However, if we choose two columns and then the output rows has to satisfy both the conditions.

The second one is the Conditions section – this is where we chose the column and perform the operation.

For now, we kept the default logical And, and then click 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.

Talend Filter Rows 6

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!

Talend Filter Rows 7

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 returns all the Customers whose Occupation is not equal to Skilled Manual.

Talend Filter Rows 8

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.

Talend Filter Rows 9

Let us run the Talend Filter Row Job.

Talend Filter Rows 10

Let me open the Management studio to check the result. Remember, Talend tFilterRow is the same as the SQL Where Clause.

Talend Filter Rows 11

This time, we are using two fields and run the job. It means Talend tFilterRow has to returns all the Customers whose Occupation is not equal to Skilled Manual and Yearly Income is greater than 50000.

Talend Filter Rows 12

Please check the Talend filter row result.

Talend Filter Rows 13

The tFilterRow component tab has an advanced option. Use this option to write a custom java code to perform filters.

Talend Filter Rows 14

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.

Talend Filter Rows 15

Please check the Talend tFilterRow result.

Talend Filter Rows 16