
Anonymous
Not applicable
2018-06-26
11:22 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How to handle division by zero error in tmap.
Hi Team,
How to handle division by zero error in tmap.
src_cols
col1 integer
col2 integer
target_cols
col integer
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.
Thanks
shree
394 Views
1 Solution
Accepted Solutions

Anonymous
Not applicable
2018-06-27
12:03 PM
Author
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Great, would you accept the solution please?
394 Views
3 Replies

Anonymous
Not applicable
2018-06-26
11:49 AM
Author
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Assuming your expression is .....
row1.col1/row1.col2
...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.
394 Views

Anonymous
Not applicable
2018-06-26
01:12 PM
Author
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @rhall,
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.
thanks
Shree
394 Views

Anonymous
Not applicable
2018-06-27
12:03 PM
Author
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Great, would you accept the solution please?
395 Views
