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

Calling Talend Open Studio Users

The first 100 community members completing the Open Studio survey win a $10 gift voucher.

Start the survey

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

6 Ways to Start Utilizing Machine Learning with Amazon We Services and Talend

Look at6 ways to start utilizing Machine Learning with Amazon We Services and Talend

Blog