How to handle division by zero error in tmap.
after applying col1/col2 in tmap i am getting below error.
Exception in component tMap_1
java.lang.ArithmeticException: / by zero
Note: col1 and col2 we have 0(Zero) values.
Solved! Go to Solution.
Assuming your expression is .....
...and assuming that if it is divided by 0 you want to return 0 (you can change this to whatever suits you), you can do this....
row1.col1==null || row1.col2==null || row1.col2.equals(0) ? 0 : row1.col1/row1.col2
I am also checking for nulls here, just in case.
I am tried below code,
row1.col1==null || row1.col2==null || row1.col2==0 ? 0 : row1.col1/row1.col2
because both are integer column type is integer.
It's worked for me.
Join us at the Community Lounge.
Talend named a Leader.
Kickstart your first data integration and ETL projects.
Watch the recorded webinar!
Pick up some tips and tricks with Context Variables
Learn how media organizations have achieved success with Data Integration
Create systems and workflow to manage clean data ingestion and data transformation.