Hi,

I'm using 'org.apache.hadoop.hive.serde2.OpenCSVSerde' to write hive table
data.
CREATE TABLE testtable ROW FORMAT SERDE
'org.apache.hadoop.hive.serde2.OpenCSVSerde'
WITH SERDEPROPERTIES (
   "separatorChar" = ",",
   "quoteChar"     = "'"
)
STORED AS TEXTFILE LOCATION '<location>' AS
select * from foo;

So, if 'foo' table has empty strings in it, for eg: '1','2','' . The empty
strings are written as is to the textfile. The data in textfile reads
'1','2',''

But if 'foo' contains null values, for eg: '1','2',null. The null value is
not written in the text file.
The data in the textfile reads '1','2',

How do I make sure that the nulls are properly written to the textfile
using csv serde. Either written as empty strings or any other string say
"nullstring"?

I tried using ""serialization.null.format" = "" in the SERDEPROPERTIES. But
that doesn't seem to work probably because csvserde doesn't support it or
its the proper use case.

Please guide me on how to write nulls to csv files.

Thanks,
Punit

Reply via email to