Tmap conditions working in test but not when executing

Seven Stars

Tmap conditions working in test but not when executing

Hello everyone,

 

I'm fronting something strange with my Tmap conditions.
I have one row in input; with field "State". This state is a string : "in stock", all my input "State" has this value. I want it to be in the output 1 if its "in stock" and 0 for any others values. So i created a var with expressions :

row7.State=="in stock"?"1":"0" 

named NewState, and linked it to my output " State". Before that, in the expression constructor, I did a test. I put as value " in stock" in row.7 state, clicked " Test " and it returned "1". I thought all was fine. But when I execute my job, all my state get "0".

 

How comes the Tmap Expression Builder's Test returns me the good value, but the output filed I get is false? What am I missing?

 

 

 


Accepted Solutions
Forteen Stars TRF
Forteen Stars

Re: Tmap conditions working in test but not when executing

You should never use == to compare 2 strings.

Use 

"in stock".equalsIgnoreCase(row7.State) ? "1" : "0" 

TRF

All Replies
Forteen Stars TRF
Forteen Stars

Re: Tmap conditions working in test but not when executing

You should never use == to compare 2 strings.

Use 

"in stock".equalsIgnoreCase(row7.State) ? "1" : "0" 

TRF
Seven Stars

Re: Tmap conditions working in test but not when executing

Thanks a lot TRF, learning every day here.

 

Solved.

 

 

Forteen Stars TRF
Forteen Stars

Re: Tmap conditions working in test but not when executing

You're welcome

TRF

Tutorial

Introduction to Talend Open Studio for Data Integration.

Definitive Guide to Data Integration

Practical steps to developing your data integration strategy.

Definitive Guide to Data Quality

Create systems and workflow to manage clean data ingestion and data transformation.