Tmap NullPointerException when converting integer to string

Five Stars

Tmap NullPointerException when converting integer to string

I'm trying to convert integer to string datatype for a column which has some null values and the data gets loaded, but keep getting java.lang.NullPointerException in my Run window.  What causes this even the data is loaded to the output table?

 

Doing conversion in tmap using Relational.ISNULL(row1.column)?nullSmiley Frustratedtring.valueOf(row1.column) 

In Tmap, output column is selected as string.

 

 

 

 

 


Accepted Solutions
Ten Stars

Re: Tmap NullPointerException when converting integer to string

Make sure in your output ... the new column is able to except null values, so if its an existing table... make sure null is allowed. 

row1.column = null
String.valueOf(row1.column) will return "null"

 

try this:

row1.column==null ? null : ""+row1.column

or:

row1.column==null ? null : Integer.toString(row1.column)

 


All Replies
Ten Stars

Re: Tmap NullPointerException when converting integer to string

Make sure in your output ... the new column is able to except null values, so if its an existing table... make sure null is allowed. 

row1.column = null
String.valueOf(row1.column) will return "null"

 

try this:

row1.column==null ? null : ""+row1.column

or:

row1.column==null ? null : Integer.toString(row1.column)

 

Five Stars

Re: Tmap NullPointerException when converting integer to string

I've tried both of these commands and it still gives me the same error.  

NOTE:  It does load null values to the output table, but the error still comes up in the run window.  Total # of input records matches the output load records.

Ten Stars

Re: Tmap NullPointerException when converting integer to string

Could you please attach your process flow... and also tmap ... Im positive something else is going wrong...
run window you mean console?
Forteen Stars

Re: Tmap NullPointerException when converting integer to string

@rp2018,try the below way. and let me know

 

 

(row1.col).toString()

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

Re: Tmap NullPointerException when converting integer to string

 Here are the screen shots of my job.  Yes, I'm getting the error message in the Run console.

 

Capture4.PNGCapture5.PNG

Ten Stars

Re: Tmap NullPointerException when converting integer to string

Looks absolutely fine... Are you sure your input table row1.column is of int type in the database table? and not a nvarchar(10) ? Could you put a logrow between input and tmap and also between tmap and output.

Note:
Some type conversion is taking place within java-code, int is a primitive type and cant be null, Integer is of object type and can be null.

What’s New for Talend Spring ’19

Watch the recorded webinar!

Watch Now

Agile Data lakes & Analytics

Accelerate your data lake projects with an agile approach

Watch

Definitive Guide to Data Quality

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

Download

Tutorial

Introduction to Talend Open Studio for Data Integration.

Watch