deal with null value

One Star

deal with null value

Hi all
In the original table in sql server,column flag was 'NULL', when i extract data from this table via talend ,and write it into delimited file , it values '',blank. How can i keep the column flag the same as 'NULL'? Except using tReplace.


Best Regards!
Joe
Community Manager

Re: deal with null value

Hi Joe
Can you please test it is null or empty on column flag as 'NULL' after you read from table? For example:
tMssqlInput--main--tJavaRow
on tJavaRow:
if(Input_row.columnName==null){
System.out.println("it is null");
}
or

if(Input_row.columnName.equals(""){
System.out.println("it is empty");
}
Let me know your test result!
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: deal with null value

Hi Shong
Yes, I have tested that already. If I write the data into delimited file first,and then write it to database,it is still empty. If I write it into table directly from one database to another,it is ok,with the ?NULL? Value. But,the table has mass data,and if i process it without delimited file ,it may lead to outofmemory exception and low efficency.
Joe
Community Manager

Re: deal with null value

Hi
Don't know why you use a demited file, but you can convert empty to null on tMap after read it from demilted file, eg:
row1.columnName.equals("")?null:row1.columnName
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: deal with null value

There isn't a null value for files, just empty. If you want to include the value null you will have to do it in your tMap.
One Star

Re: deal with null value

Thank you shong and janhess
another problem,If the project that i shall do contains a lot of data(more than10,000,000 rows),how can i avoid the outofmemory exception? now we take the way of storing the data into files first ,and then reading data from file on disk . It seems to work fine,except a little slow. Is there any other better ways?
there will be several jobs running parallelly,so we must take care of the memory.

joe

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

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch 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