How to create a float by dividing two 'int's?

One Star

How to create a float by dividing two 'int's?

Hi,
I'd like to generate a calculated metric in my Talend job, namely a percent
At this point I have tried dividing two integer columns A / B in a tMap with the data type set to Float
I'm not getting decimal values through to my MySQL table; they're showing up as integers
My MySQL column is set to decimal data type length of '5,2'
I don't have a length specified in my Talend schema as I didn't know how to express it
Could use some help in getting my percentage working Smiley Happy
Thanks
Four Stars

Re: How to create a float by dividing two 'int's?

Use (float) to convert your integer number division to float in tMap. say (float)(A/B). You already have your output column as float. So it should work.
Vaibhav
One Star

Re: How to create a float by dividing two 'int's?

Hi, and thanks Smiley Happy
I ended up just using the (float) on the first int, since that also works:
(float)row.col1/row.col2

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

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog