Missing something easy with this conditional

Highlighted
Five Stars

Missing something easy with this conditional

Hi All,

 

In tMap I have the following expression:

StringHandling.TRIM(row2.country) == "Germany"?"EMEA":"UNKNOWN"

But for some reason all the values, regardless of the value of "row2.country" are all coming up as "UNKNOWN" including the ones that have a value of "Germany".

I have checked the incoming data and it is correct (initialized just like in the equation).

I am sure I am missing something simple but it is escaping me.

Thanks.


Accepted Solutions
Eight Stars

Re: Missing something easy with this conditional

@Craigbert ,

 

Please try changing the condition to

StringHandling.TRIM(row2.country).equals("Germany")?"EMEA":"UNKNOWN"

 

and see if it works.

For strings, it is usually done this way 


All Replies
Eight Stars

Re: Missing something easy with this conditional

@Craigbert ,

 

Please try changing the condition to

StringHandling.TRIM(row2.country).equals("Germany")?"EMEA":"UNKNOWN"

 

and see if it works.

For strings, it is usually done this way 

Eight Stars

Re: Missing something easy with this conditional

String value comparison should be done with .equals() method and not == operator. Double equals is for object reference comparison
Five Stars

Re: Missing something easy with this conditional

Thanks to you both!  That solved my problem!

 

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 2

Part 2 of a series on Context Variables

Blog

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog