tmap expression syntax

Highlighted
Five Stars

tmap expression syntax

i have tried below expression in tmap as per expectation i should get  " null " as output in tmap test editor ..but getting  "n" as output ...could you please clarify this...

 

talend22.PNG


Accepted Solutions
Highlighted
Employee

Re: tmap expression syntax

@lavan524 

 

Or try this way where the code is checking whether you are sending input itself as "null".

 

 

Relational.ISNULL(row1.data) || row1.data.trim().equals("")|| row1.data.trim().toLowerCase().equals("null")?null:row1.data.substring(0,1).toLowerCase()

 

 

But the caveat is that sending null as a string is a bad practice.

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved :-)

View solution in original post


All Replies
Highlighted
Moderator

Re: tmap expression syntax

@lavan524 ,that hole expression will return a single character ,let think this way you have null as string with that expression will return only n ,if you changed 1 to 3 it will return nul

Manohar B
Don't forget to give kudos/accept the solution when a replay is helpful.
Highlighted
Employee

Re: tmap expression syntax

Hi,

 

Please try like below.

 

Relational.ISNULL(row1.data) || row1.data.trim().equals("")?null:row1.data.substring(0,1).toLowerCase() 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved :-)

Highlighted
Five Stars

Re: tmap expression syntax

i have tried this way but still getting same output 

 

tal12.PNG

Highlighted
Employee

Re: tmap expression syntax

Hi,

 

    Could you please print the input and output side by side to a tLogrow and share it with us? We would like to see the input data you are passing.

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved :-)

Highlighted
Moderator

Re: tmap expression syntax

@lavan524 ,do you understand my answer,if not for that column have null values as string which means "null" has took as for that column with your expression returns only one character for "null" data the first character is n,so thats why you see n 

Manohar B
Don't forget to give kudos/accept the solution when a replay is helpful.
Highlighted
Five Stars

Re: tmap expression syntax

Actually i am trying  to test expression in tmap test editor ...as per expectation by default value should be null and as per expression out put should be  " null " but getting " n "


Relational.ISNULL(row1.S_Name_Indexed__c) || row1.S_Name_Indexed__c.trim().equals("")?null:row1.S_Name_Indexed__c.substring(0,1).toLowerCase()

Highlighted
Moderator

Re: tmap expression syntax

@lavan524 ,if you want null then change this way.

 

Relational.ISNULL(row1.S_Name_Indexed__c) || row1.S_Name_Indexed__c.trim().equals("")?null:row1.S_Name_Indexed__c.substring(0,4).toLowerCase()

Manohar B
Don't forget to give kudos/accept the solution when a replay is helpful.
Highlighted
Employee

Re: tmap expression syntax

@manodwhb  has already explained it.

 

You are trying to insert null as a string "null" or "Null" or "NULL". But as per java, if it has to consider a value as null, it should be empty like a black hole.

 

You cannot equate it with any value as string.

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved :-)

Highlighted
Employee

Re: tmap expression syntax

@lavan524 

 

Or try this way where the code is checking whether you are sending input itself as "null".

 

 

Relational.ISNULL(row1.data) || row1.data.trim().equals("")|| row1.data.trim().toLowerCase().equals("null")?null:row1.data.substring(0,1).toLowerCase()

 

 

But the caveat is that sending null as a string is a bad practice.

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved :-)

View solution in original post

Highlighted
Five Stars

Re: tmap expression syntax

I just want to clarify one thing .. as per ternary expression 

 

Condition ? True : False

 

Relational.ISNULL(row1.S_Name_Indexed__c) || row1.S_Name_Indexed__c.trim().equals("")?null :row1.S_Name_Indexed__c.substring(0,1).toLowerCase()

 

in my case condition is true and i should get "null" as result but why i am getting  "n" as out put

Highlighted
Employee

Re: tmap expression syntax

Hi,

 

   It is because you are sending a string called "null". It is not equal to actual null in Java. But if you are insisting that you would like to send null as String, please try the code in previous post.

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved :-)

2019 GARTNER 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

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