How to manage null value with tFilter

Highlighted
Six Stars

How to manage null value with tFilter

Hi, I have a problem handling null values in my tFilter.

 

My tFilter condition :

 

( input_row.COMPANY_CODE.equals("31") || input_row.COMPANY_CODE.equals("14") )  && !(input_row.DESCRIPTION.equals("SUB-TOTAL :")) && !(input_row.DESCRIPTION.equals("TOTAL :"))

I have this error ODS_BALANCE_CSV_TEMP - tFilterRow_3 null

 

there're null values in the columns of the table that I'm trying to filter. Before I had a classic filter but since I need to combine the conditions OR and AND, I have to do it in java.

 

How to overcome this problem?

Thank you

 

 


Accepted Solutions
Highlighted
Nine Stars

Re: How to manage null value with tFilter

You could use the Advanced mode of tFilterRow and have your java code filter out the NULL records.

 

tFilterRow-4.JPG 

View solution in original post


All Replies
Highlighted
Employee

Re: How to manage null value with tFilter

Hi,

 

     You will have to assign either true or false for the null condition by catching them. Please see the screen shot below for a simple example.

      Here, if the input data is coming as null, then we are converting it into either true or false based on the condition. You will have to do null check condition before going to equal condition clause. Then it will work fine.

 

image.pngIf you think the suggestion given has helped you, please mark it as acceptable solution.

 

Warm Regards,

 

Nikhil Thampi

Highlighted
Nine Stars

Re: How to manage null value with tFilter

You could use the Advanced mode of tFilterRow and have your java code filter out the NULL records.

 

tFilterRow-4.JPG 

View solution in original post

Highlighted
Six Stars

Re: How to manage null value with tFilter

Thanks for you explanation Smiley Happy
Highlighted
Six Stars

Re: How to manage null value with tFilter

Thanks, it works fine
Highlighted
Five Stars

Re: How to manage null value with tFilter

Nikhil,

 

I tried your syntax for passing through a null field and asking for a filter.   I wrote it like this

(Relational.ISNULL(input_row.Reason_Code)?true:false) && !input_row.Reason_Code.equals("334"))

 

It's still providing a null pointer exception.   Do you know what the issue could be?

Five Stars

Re: How to manage null value with tFilter

Nevermind I figured it out.  I had the parenthesis in wrong spots

2019 GARTNER 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

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog