Search code examples
talend

Filtering column strings that contain substring


I am working on an if else in the Tmap, and one of the conditions is if a column contains a substring.

I am unsure exactly how to go about this being fairly new to talend.

This is the current syntax that I am using.

row16.Location.contains("clos")?"Pending":""

I have not been able to find any good examples of the correct way to go about this, other than the one above.


Solution

  • Talend uses Java as an underlying language, so you need to use the ternary operator of Java:

    row16.Location.contains("clos") ? "Pending" : ""
    

    But make sure you first check row16.Location for null, otherwise you'll get a NullPointerException if Location is null :

    row16.Location != null && row16.Location.contains("clos") ? "Pending" : ""