How to identify tMap errors in Talend
In this “how to” you will see a tMap functionality that makes it a lot easier to debug tMap errors, especially when you are using a lot of data, columns or converts.
Before I knew about this functionality I used to spent a lot of time on solving nullpointer exeptions and all kind of convert errors. I took smaller datasets or removed output columns to solve my issues.
I think this “how to” is going to save you a lot of time during future Talend developments.
1. Create a new job
- Name your job “how_to_fix_tMap_errors”
2. Add the input data
I have used the tFixedFlowInput component in this “how to”, but you can use any other data input component.
- Add the tFixedFlowInput component to your canvas
- Edit the schema
- Select mode “Use Inline Content(delimited file)”
- Add row separator “\r\n”
- Set field separator “|”
- Add content:
AA|Jeans|1.2|
BB|Jeans2|1.3|1
CC|Jeans3|1.4|2
3. Add tMap component
- Add the tMap component
- Connect the tFixedFlowInput to the tMap component (Row – Main)
- Add output “out1”
- Drag the columns from the left to the right
- Change the data type of the quantity column to “Integer”
- Add the convert to the Quantity column (Integer.parseInt(row1.Quantity)
4. Add the output
In this “how to” i’m using the tLogRow component to show you the output, but you can use any type of output component
- Add the tLogRow component to your canvas
- Connect the tMap component to the tLogRow (Row – Main)
- Select Mode – Vertical
5. Run your job
You should get an error because of the null value that you are converting from string to integer.
6. Die on error option
Now we are going to add an extra output flow to the tMap component so you can identify the record(s) that are causing the error.
- Open you tMap component
- Press the “Setup the configuration of tMap” button at the upper left corner.
- A new window pops up
- Uncheck the “Die on error” option and click OK
- You can see that the ErrorReject output has been added
- Go back to your canvas and add an extra tLogRow component
- Select Mode – Vertical and go back to your canvas
- Right click you tMap component. You will notice that the “ErrorReject” output flow shows up
- Connect you tMap component to the second tLogRow component (Row – ErrorReject)
7. Run your job
When you run your job you will see that the record that causes the error gets handled by the ErrorReject flow
It will give the following output to your console
Because you want to identity the record that realy causes the error you should add the input columns to your “ErrorReject” output
Run your job again to see the output below: