Talend tMap filter rows

In this Talend article, we show how to use the Talend tMap component to filter rows based on the expression. We can use the tMap as an alternative to tFilterRow to filter rows or records in a table.

To demonstrate the Talend tMap filter rows, we use the same Customer data that we used in the tFilterRow example. So, let me use the tDBInput to select the table.

Configure Server Connection and write table Select query

Drag and drop the Talend tMap into the job design, and connect the tDBInput Main row to tMap.

Talend tMap Filter Rows 2

Double-click on the tMap will open the following window.

Talend tMap filter rows Example

Click the Plus (+) button to add a new output to this Talend tMap, and we named it Filtered_Rows.

Talend tMap Filter Rows 4

Drag all the available columns in row1 to Filter_Rows output. Next, please click on the little expression icon will open an empty space to write an expression.

Write an expression

The following expression will show you the customers whose Occupation is not equal to Clerical.

Talend tMap Filter Rows 7

Let me use the tLogRow to display the Talend tMap filter rows output. To do this, add the tLogRow to the workflow and connect the tMap main row to it. Next, within the tLogRow component tab, choose the table option. Please run the Talend tMap filter rows job to see the output.

Run the Talend tMap Job to Filter Rows

We can also write multiple expressions or conditions to filter the output rows. To write the complex expression or if you don’t know the function names, please click on the browse button. It opens the expression builder and uses it to view all the available built-in functions of the Talend. Here, we added one more condition that filters employees whose yearly income is greater than 50000.

Complex multiple expressions to filter

You can see all the records whose income is greater than 50000 and whose Occupation is not equal to Clerical.

Talend tMap Filter Rows result

Next, we added one more output to show the rejected rows and added all the rows to it.

Set Rejected rows

Please change the Catch output reject option from default false to True. Next, click the OK button to close the Talend tMap window.

Change the Cache output rejected rows option to true

Now, you can see the rejected rows or rows don’t meet the expression. 

Talend tMap Filter Rows Final Preview