Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Jj5
Contributor III
Contributor III

[resolved] Is there an easier way to handle nulls in tMap with lots of fields?

I've been working on a project where I have to map close to 100 fields. Everything was working perfectly, but I never got in the habit of testing for nulls. That came back to bite me because I was given a new file that had null values.
Currently the only way I know how to handle nulls are to use the following code in the expression editor:
FIELD != null && FIELD.length() > 0 ? FIELDVALUE : null
Since I have around 100 fields, editing every single expression to do this will take a lot of time. Is there an easier way?
Labels (2)
1 Solution

Accepted Solutions
Anonymous
Not applicable

hi all,
as willm as said it's our job to manage data & null value 0683p000009MA9p.png
Is it normal that you've got so much empty or null value ? Profile your data sources to check percentage of null values if necessary ...
but never mind , it 's not your need at that case I guess 0683p000009MACn.png
tSchemacComplianceCheck has en advanced options that can "convert" empty fields in null value.

hope it helps
regards
laurent
0683p000009MDDo.png

View solution in original post

5 Replies
willm1
Creator
Creator

The question I'd have to ask is - what do you do when you hit nulls? Reject the record or route it for reprocessing? You can use the tSchemaComplianceCheck upstream to filter and segregate your records and you can use the codes in the error message to process the colums in a subsequent job - see the bottom of https://help.talend.com/search/all?query=tSchemaComplianceCheck&content-lang=en
Else you can use a tReplace... Or (much harder - I know you're looking for easy!), tJavaRow...
It might be a lot of work, once you do it, you'll sleep well knowing your job is resilient to null pointer errors...
Jj5
Contributor III
Contributor III
Author

The question I'd have to ask is - what do you do when you hit nulls? Reject the record or route it for reprocessing? You can use the tSchemaComplianceCheck upstream to filter and segregate your records and you can use the codes in the error message to process the colums in a subsequent job - see the bottom of https://help.talend.com/search/all?query=tSchemaComplianceCheck&content-lang=en
Else you can use a tReplace... Or (much harder - I know you're looking for easy!), tJavaRow...
It might be a lot of work, once you do it, you'll sleep well knowing your job is resilient to null pointer errors...

If the field is empty I want it replaced by null, it doesn't matter if there are null values in the output, I just want the NullPointerException to go away. It seems weird to me that we have to test if the field is empty and manually set it to null, I figured Talend would see an empty field as null to begin with normally.
willm1
Creator
Creator

Hi jeanjpotgieter - null pointer exceptions are among the most common Java errors. No need to defend Talend here, but because it generates java code, you have to deal with constraints of the coding language at certain points in your code, especially when you're processing and 'touching' your data.
There are tons of old posts on this forum on this error and they all have similar solutions to what I suggested; but you already know all of them and unfortunately, they don't provide that quick fix you're looking for...
Jj5
Contributor III
Contributor III
Author

Hi jeanjpotgieter - null pointer exceptions are among the most common Java errors. No need to defend Talend here, but because it generates java code, you have to deal with constraints of the coding language at certain points in your code, especially when you're processing and 'touching' your data.
There are tons of old posts on this forum on this error and they all have similar solutions to what I suggested; but you already know all of them and unfortunately, they don't provide that quick fix you're looking for...

That's what I was afraid of. I guess I'll just spend the weekend cleaning out my files. At least I'll know to do this next time. Thanks for the help.
Anonymous
Not applicable

hi all,
as willm as said it's our job to manage data & null value 0683p000009MA9p.png
Is it normal that you've got so much empty or null value ? Profile your data sources to check percentage of null values if necessary ...
but never mind , it 's not your need at that case I guess 0683p000009MACn.png
tSchemacComplianceCheck has en advanced options that can "convert" empty fields in null value.

hope it helps
regards
laurent
0683p000009MDDo.png