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.
Drag and drop the Talend tMap into the job design, and connect the tDBInput Main row to tMap.
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.
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.
The following expression will show you the customers whose Occupation is not equal to Clerical.
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.
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.
You can see all the records whose income is greater than 50000 and whose Occupation is not equal to Clerical.
Next, we added one more output to show the rejected rows and added all the rows to it.
Please change the Catch output reject option from default false to True. Next, click the OK button to close the Talend tMap window.
Now, you can see the rejected rows or rows don’t meet the expression.