Skip to main content
Announcements
Global Transformation Awards! Applications are now open. Submit Entry
cancel
Showing results for 
Search instead for 
Did you mean: 
ali_hijazi
Partner - Master II
Partner - Master II

Insert null in a column of data type Double

Hello 
I'm working on Talend studio, I have a t_Map
I have a column of type double; 
I'm writing the following expression :


row3.t_fixed != null && row3.t_fact != null
?
row3.t_fixed != 0 || row3.t_fact == 0 
?
null
:
row3.r_std
:
null

 

However I'm getting an error saying it's nullPointer Exception
If I replace null with zero the job works fine, but I don't want to put zero but rather null

Kindly advise

I can walk on water when it freezes
Labels (3)
8 Replies
marksouzacosta

Hi @ali_hijazi,

Can you please add a screen shot of your tMap Output Schema and also the log error?

Read more at Data Voyagers - datavoyagers.net
Follow me on my LinkedIn | Know IPC Global at ipc-global.com

ali_hijazi
Partner - Master II
Partner - Master II
Author

Hello @marksouzacosta 
sorry for the late notice

ali_hijazi_0-1728309973136.png

Here is a screen shot of the tmap component
I created a variable called var_tarrifstd of type double
and this is the definition:
when I use null I get an error but when I use null the job works successfully

ali_hijazi_1-1728310108298.pngali_hijazi_2-1728310308862.png

 

 

I can walk on water when it freezes
fcolagiacomo
Contributor III
Contributor III

The code is Ok, I don't have the error.

row3.t_fixed != null && row3.t_fact != null
?
row3.r_std
:
null

Are you sure the error is in tarifstd field?

 

ali_hijazi
Partner - Master II
Partner - Master II
Author

Yes the error is raised in tmap component while the field is nullable.

When I put zero then the job finishes successfully 

I can walk on water when it freezes
marksouzacosta

Can you try to replace your whole variable code to just return null and add a tLog after the tMap (deactivating for now the nodes after the tMap)?

Your schemas are looking good so I'm just making sure the problem is in your tMap and on that field.

Read more at Data Voyagers - datavoyagers.net
Follow me on my LinkedIn | Know IPC Global at ipc-global.com

fcolagiacomo
Contributor III
Contributor III

Can you make some examples with input values for row3.t_fixed, row3.t_fact, row3.r_std and expected values?

Could you show me the code for variable var_r_currency?

Thanks

ali_hijazi
Partner - Master II
Partner - Master II
Author

it's the same:

ali_hijazi_0-1728403996655.png

but the field currency is of type string and it accepts null as value
I'm pretty sure there is something special about null in double data type

I can walk on water when it freezes
fcolagiacomo
Contributor III
Contributor III

Hi,

I believe I understand where the problem is.

You are right! If you use a var in tMap as double, Talend build the code like this: 

class Var__tMap_1__Struct {
  double var1;
}

So you cannot use null value.

The solution is:

You haven't to use your code in Var field but you have to insert it directly in field Expression of tarifstd.