[resolved] Null pointer on tMap expression

Highlighted
One Star

[resolved] Null pointer on tMap expression

I'm new to talend so please let me know if I'm going about this the right way.
So far I have a job that is going from MySqlInput ---> tMap -----> Salesforce

In the tMap expression editor I'm trying to recreate the following part of the query to label time zones:

CASE brZone
WHEN '1' THEN 'America/Los_Angeles'
WHEN '2' THEN 'America/Denver'
WHEN '3' THEN 'America/Chicago'
WHEN '4' THEN 'America/New_York'

From looking through everything I could find on these forums relating to cases, I came up with this:

row1.brZone.equals("1")?"America/Los_Angeles":row1.brZone.equals("2")?"America/Denver":row1.brZone.equals("3")?"America/Chicago":row1.brZone.equals("4")?"America/New_York"Smiley Sadrow1.brZone == null)?" ":" "

(all the fields are strings, not integers or anything else)
I guess I'm dealing with the null incorrectly? Since I keep getting a null pointer exception. The problem is, some of the data does not have a time zone associated with it and that's what I believe is tripping me up.

I'm also not sure how to end these expressions, thats also something I couldn't find. Is that the default case if none the other conditions are met?

Thank you!
Moderator

Re: [resolved] Null pointer on tMap expression

Hi,
row1.brZone.equals("1")?"America/Los_Angeles":row1.brZone.equals("2")?"America/Denver":row1.brZone.equals("3")?"America/Chicago":row1.brZone.equals("4")?"America/New_York"Smiley Sadrow1.brZone == null)?" ":" "

You should consider the situation of "null" at first.
Please see my screenshots for details

Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
One Star

Re: [resolved] Null pointer on tMap expression

Ah, thank you so much!
That fixed it right up. Smiley Happy
Moderator

Re: [resolved] Null pointer on tMap expression

Hi,

You are welcome, feel free post your issue on forum.

Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
One Star

Re: [resolved] Null pointer on tMap expression

Hi,

I have a date field of date type in my schema.How can i get rid of the null value in date fields records.
I mean i wanted to skip those records
One Star

Re: [resolved] Null pointer on tMap expression

Hi,
I have a situation, I have source table and from that i am spliting data into 2 table on the basis of some validation on columns.
validation :  Suppose i have Name column and its length is 10 but in some cases i found that Name column has values more than the length(10) . so in this case i want to split data in to 2 tables .
if values are greater than length then it goes to ERROR table and value is equal or less than length then it goes to proper Target table.

&
I have done with given situation with this logic row1.TRINAMETX.length()>10 
But,
I am getting error....
Starting job Job_Geography_triCountry_Part_1 at 15:03 11/09/2015.
[size=1][font=Verdana, Helvetica, Arial, sans-serif][statistics] connecting to socket on port 4008
[statistics] connected
Exception in component tMap_1
java.lang.NullPointerException
at demo.job_geography_tricountry_part_1_0_1.Job_Geography_triCountry_Part_1.tFileInputExcel_1Process(Job_Geography_triCountry_Part_1.java:3648)
at demo.job_geography_tricountry_part_1_0_1.Job_Geography_triCountry_Part_1.runJobInTOS(Job_Geography_triCountry_Part_1.java:6206)
at demo.job_geography_tricountry_part_1_0_1.Job_Geography_triCountry_Part_1.main(Job_Geography_triCountry_Part_1.java:6065)
[statistics] disconnected
Job Job_Geography_triCountry_Part_1 ended at 15:03 11/09/2015. [exit code=1][/font][/size]

Waiting for the Reply?
Thanks in Advance.


Regards,
Shriram
Talend User.

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

Have you checked out Talend’s 2019 Summer release yet?

Find out about Talend's 2019 Summer release

Blog

Talend Summer 2019 – What’s New?

Talend continues to revolutionize how businesses leverage speed and manage scale

Watch Now

6 Ways to Start Utilizing Machine Learning with Amazon We Services and Talend

Look at6 ways to start utilizing Machine Learning with Amazon We Services and Talend

Blog