title: Writing columns having NULL as some string using OpenCSVSerde - HIVE
body: <p>I'm using 'org.apache.hadoop.hive.serde2.OpenCSVSerde' to write hive table data.</p>
  
  <pre><code>CREATE TABLE testtable ROW FORMAT SERDE  'org.apache.hadoop.hive.serde2.OpenCSVSerde'
  WITH SERDEPROPERTIES (
    "separatorChar" = ","
    "quoteChar"     = "'"
     )  
  STORED AS TEXTFILE LOCATION '&lt;location&gt;' AS
  select * from foo;
  </code></pre>
  
  <p>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',''</p>
  
  <p>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',  </p>
  
  <p>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"?</p>
  
  <p>I also tried this:</p>
  
  <pre><code>CREATE TABLE testtable ROW FORMAT SERDE
  ....
  ....  
  STORED AS TEXTFILE LOCATION '&lt;location&gt;'
  TBLPROPERTIES ('serialization.null.format'='')
  AS select * foo;
  </code></pre>
  
  <p>Though this should probably replace the empty strings with null. But this doesn't even do that.</p>
  
  <p>Please guide me on how to write nulls to csv files.</p>
  
  <p>Will I have to check for the null values for columns in the select query itself like (NVL or something) and replace it with something?</p>