You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hive.apache.org by Binal Jhaveri <bi...@gmail.com> on 2015/01/26 19:05:24 UTC

convert empty strings to null

My input file is a json file. I am loading that into a staging table. Then
i am parsing the json using hive (Lateral view and json_tuple) and writing
to a final avro table. My issue is some json values have empty strings. I
want those empty strings to display as null..
what is the best way to achieve this??

Re: convert empty strings to null

Posted by Devopam Mittra <de...@gmail.com>.
You may simply try the below if it helps...

CASE LENGTH(colname) WHEN 0 THEN NULL ELSE colname

if needed , use substring to derive the 'colname' from your json tuple..
and apply / extend the same logic

regards
Dev



On Mon, Jan 26, 2015 at 11:35 PM, Binal Jhaveri <bi...@gmail.com> wrote:

> My input file is a json file. I am loading that into a staging table. Then
> i am parsing the json using hive (Lateral view and json_tuple) and writing
> to a final avro table. My issue is some json values have empty strings. I
> want those empty strings to display as null..
> what is the best way to achieve this??
>



-- 
Devopam Mittra
Life and Relations are not binary