
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Tmap expression always false
I an joining a tfileinput and a table in tamp and comparing two integer fields. My condition looks like this
row1.rec_count==row2.lz_count?0:1
However, the condition is always failing even though the counts match (I checked the output with a tlogrow) and both rec_count and lz_count are defined as integer. Do you have any idea why?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
Could you please post your tMap editor screenshot on forum? Did you put your condition in tMap expression field?
Best regards
Sabrina

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@pnair123,condition is right one,if you have configured your tMap correctly then the problem with data.
Please check.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@pnair123,condition is right one,if you have configured your tMap correctly then the problem with data.
Please check.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Do you use the 0 or 1 as a bit/boolean?
Change it's value in true or false and type boolean

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for your suggestion. I figured out the issue. One field was defined as integer and other was defined as integer(11). When I changed both to integer(11), it worked.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for your post and solving the issue!!!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
NO this is not the actually reason. The length of a data type will never be used within the job! Such settings only are used when the job has to create the table for itself.
The reason why your expression is not working is because you have to think about what == actually means in Java!
It means the SAME content of the variable! If you have both values as none nullable integer, then both variables have the same content.
If you have nullable Integer the variables actually contains the addresses of the Integer objects and in most cases both Integer objects are using different addresses within the RAM. The only Java like language dealing with it in a human way is Groovy.
if you compare a nullable Integer with a not nullable int value the Integer value will be converted implicit into the primitive value and now the == works well. If you have both values a not nullable you have to check both for being not null and than use the equals method!
Example:
(i1 != null && i1.equals(i2))
this is save and will always work!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Started reading a little bit to fully understand what you are saying. So in addition to what you where saying with examples:
https://stackoverflow.com/questions/1514910/how-to-properly-compare-two-integers-in-java
