Calculating Precentage of Int but get exception in thread error in tMap

Seven Stars

Calculating Precentage of Int but get exception in thread error in tMap

In my tMap I have an input flow with an integer value and I need to calculate a set percentage of it for output flow. 

 

(row1.Integer_Numeric/100*45) 

Is the calculation I have in the expression builder of a float variable but no matter what value I have for row1.Integer_Numeric I get 0 in the output flow without any compiler errors when I run the job.

 

If I use the test feature in expression builder I get

Exception in thread "main" java.lang.Error: Unresolved compilation problems

 

Do I need to cast the result of the calculation to a float within the expression builder or use a different datatype in the output flow?


Accepted Solutions
Seven Stars

Re: Calculating Precentage of Int but get exception in thread error in tMap

It seems I needed to convert the integer to a float value first using 

row1.Integer_Numeric.floatValue()

so that the calculation would work. I incorrectly assumed just the result needed to be a float when the input value was integer

View solution in original post


All Replies
Seven Stars

Re: Calculating Precentage of Int but get exception in thread error in tMap

Also the calculation seems only to work when the integer value is 100 ie. a number without a decimal place

Seven Stars

Re: Calculating Precentage of Int but get exception in thread error in tMap

It seems I needed to convert the integer to a float value first using 

row1.Integer_Numeric.floatValue()

so that the calculation would work. I incorrectly assumed just the result needed to be a float when the input value was integer

View solution in original post

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