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
Highlighted
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


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

Highlighted
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

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 4

Pick up some tips and tricks with Context Variables

Blog

How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration

Read

Definitive Guide to Data Integration

Practical steps to developing your data integration strategy.

Download