Convert String to BigDecimal in tMapJoin

Six Stars

Convert String to BigDecimal in tMapJoin

Hi, in my tMap I'm joining two tables, but I've discovered that the join fields are one a String and one a BigDecimal. The output must be a String. I used the method "toString()" on the BigDecimal field, but it keeps telling me that it cannot convert from String to BigDecimal, which I don't understand since I'm doing the opposite operation.

Forteen Stars

Re: Convert String to BigDecimal in tMapJoin

@Mary,can you provide sample date which are you going to String to BigDecimal? I believe there could be data issue.

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

Re: Convert String to BigDecimal in tMapJoin

Try something like this - 

String.valueOf((row1.bigDecimalField).doubleValue())
Ten Stars

Re: Convert String to BigDecimal in tMapJoin

could you provide a tMap screenshot please?

- And why to String??? 
- And if your output is towards a table and its "Create if not exists" setting , when you altered your tMap there's still a problem your table still is BigDecimal ...

 

However.... an important sidenote :

 

BigDecimal bgd = new BigDecimal(8.0001)
System.out.println(bgd.toString());
// the output could be : 8.0000999999999998765981265985983427124042342

It will get the closest value So your join goes wrong, instead of the above code, this should be used: 

 

 

BigDecimal bgd = new BigDecimal.valueOf(8.0001)

I hope Talend conversion works in this way...

 

 

 

 

Highlighted
Forteen Stars

Re: Convert String to BigDecimal in tMapJoin

@Mary,still you have issue,please check the below link.

https://community.talend.com/t5/Design-and-Development/String-to-BigDecimal-conversion-issue/m-p/130...

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

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

Best Practices for Using Context Variables with Talend – Part 2

Part 2 of a series on Context Variables

Blog

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog