In this Talend article, we show how to use the Talend tMap component to filter rows based on the expression. We can use the Talend 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.
Click the Plus (+) button to add a new output to this Talend tMap, and we named it as Filtered_Rows.
Drag all the available columns in row1 to Filter_Rows output.
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.
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, use 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 Occupation 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.
Click the Ok button to close the Talend tMap window.
Now, you can see the rejected rows or rows doesn’t meet the expression.