Five Stars

tmap error

when I run the job it starts perfectly but in between it stops and gives null pointer  exception

what should I do plz any one help me

thanks in advance 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Ten Stars

Re: tmap error

This is usually an indication that one of the expressions in your tMap uses a schema value in a way that doesn't handle null values.  This guide by our own @rhall_2_0 walks through the steps of creating an error output in a tMap component that will show you which row(s) cause the error:
https://www.rilhia.com/quicktips/quick-tip-how-debug-tmap-errors

15 REPLIES
Ten Stars

Re: tmap error

This is usually an indication that one of the expressions in your tMap uses a schema value in a way that doesn't handle null values.  This guide by our own @rhall_2_0 walks through the steps of creating an error output in a tMap component that will show you which row(s) cause the error:
https://www.rilhia.com/quicktips/quick-tip-how-debug-tmap-errors

Six Stars

Re: tmap error

In general, you get null pointer exception tMap if your performing any string operations on null data like (<string>.split(",")) [If this is case can handle the null by following syntax <string> != null ? <string>.split(",") : null] one of the use-case, if possible please share the tMap screenshot for more accuracy    

Moderator

Re: tmap error

Hello,

Could you please post your current job setting screenshots on forum which will be helpful for us to address your issue?

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.
Five Stars

Re: tmap error

Capture1.PNGCapture2.PNGthese are the componentsthese are the componentsthese are the joinsthese are the joins

Five Stars

Re: tmap error

there are 5 customer tables with different aliases

row3;c.customer

row7:cs.customer

row11:dc.customer

row12Smiley Surprisedc.customer

row19:scu.customer

and two similar tables with different aliases

src.pin_config

drs.pin_config

and two cell_location tables with aliases

cla.cell_location

clc.cell_location

Five Stars

Re: tmap error

and also suggest me how to give right outer join in talend tmap component

Ten Stars

Re: tmap error

If all those tables are in the same database, would it not make more sense to do the joins on the database side?

 

To address your original issue, it looks like there are two tMap output field that use a formula: SOURCE_BALANCE_B... and DESTINATION_BALANCE...

 

To avoid null pointer exceptions, you'll probably want to check each field used for nulls and set an appropriate result for that case. (e.g. row18.TOTAL_QUOTA_BEFORE == null ? 0 : <your formula here>)  If you show the entire expression, we can help write the expression to handle nulls for all fields involved.

Five Stars

Re: tmap error

row18.total_quota_before==null?0:<which formula to be used here> l'm not getting

you want to see formula in the  expression builder...

 

Five Stars

Re: tmap error

its not row18 total_quota_before is from row1 and here are the expression builder pics Capture.PNGCapture6.PNG

Ten Stars

Re: tmap error

If you attempt to use a field in an expression and one of the values on one of the rows is null, you're going to get null pointer exceptions. You can identify the offending rows by following the guide in the link I posted, or you can make sure you handle nulls in all of your expressions.
Twelve Stars

Re: tmap error

@cterenzi is correct. You either need to find the fault (find the null ) and prevent it from happening OR you need to put some logic in your expressions to mitigate for nulls.

 

For example (not using your expressions) if I want to check for a String value of "red" in a column and return a true if it is there AND prevent a null pointer exception I could use the following code in the expression to actively handle the situation where my String column is null

row1.myString!=null ? row1.myString.compareToIgnoreCase("red")==0 : false

The above is an in-line IF and says "If myString is not null AND if it contains 'red' then return true, otherwise return false"

Rilhia Solutions
Ten Stars

Re: tmap error

in additional to all above answers and recommendations

 

You can balance, where to manage nulls?:

  • You can manage it in Talend, as many time suggested
  • or You can manage it by Database 

In Your case it could make tMap more clean and not overloaded 

 

For manage nulls by database You can change tMSSQLInput query and add COALESCE function for columns used in tMap formulas

SELECT
    COALESCE(col1,0) as col1,
    COALESCE(col2,0) as col2
FROM table
WHERE
....


I prefer this way, because:
1) as I wrote it make tMap more readable
2) because SQL query it is plain text - I can use text edit with Search/Replace for change prepared query, and it faster than manually edit each tMap element

Note - it not help You in case divide by 0 - this is You need handle right in tMap if necessary 

 

 

 

-----------
Five Stars

Re: tmap error

Thank you for your support

Five Stars

Re: tmap error

Thank you for your support,I will try it

Five Stars

Re: tmap error

thanks for your support..