Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Tasfiahm
Creator
Creator

String to BigDecimal conversion issue

I am having a common and simple issue with String to BigDecimal conversion. 

 

Input: string

Output: BigDecimal

column name: Id

Inside t-map I am putting the below code in One2One mapping.

 

(Id.isEmpty() || Id.equals("")) ? null : new BigDecimal(Id)

 

I don't see any error in Code view but after running I am seeing the error. I have also tried

(Id.isEmpty() || Id.equals("")) ? null : java.math.BigDecimal(Id)

 

 

Execution Error

[statistics] connected
[FATAL]: talend_default.Ex_Job- tMap_2 null
Exception in component tMap_2
java.lang.NumberFormatException
at java.math.BigDecimal.<init>(Unknown Source)
at java.math.BigDecimal.<init>(Unknown Source)
at java.math.BigDecimal.<init>(Unknown Source)
at Ex_Job.tMSSqlInput_1Process(Ex_Job.java:2923)
at Ex_Job.tMSSqlConnection_1Process(Ex_Job.java:1011)
at Ex_Job.tMSSqlConnection_3Process(Ex_Job.java:781)
at Ex_Job.runJobInTOS(Ex_Job.java:4806)
at Ex_Job.main(Ex_Job.java:4585)

 

 

 

 

Labels (3)
1 Solution

Accepted Solutions
vboppudi
Partner - Creator III
Partner - Creator III

May be you are getting non numeric values in ID from source like space or alpha numeric.

 

Regards,

View solution in original post

4 Replies
vboppudi
Partner - Creator III
Partner - Creator III

May be you are getting non numeric values in ID from source like space or alpha numeric.

 

Regards,

manodwhb
Champion II
Champion II

@Tasfiahm,can you try to run with Debug mode and see the data,which is failing in tMap? 

use the below expression should work as default if there is no data issue

 

Id== null || "".equals(Id)?null : new BigDecimal(Id)

Tasfiahm
Creator
Creator
Author

You are exactly right. As the data was coming as a string, it was also coming with space, so I have to trim the row before applying the BigInt conversation.

manodwhb
Champion II
Champion II

@Tasfiahm. please accept the solution,which one is right.