Support Questions
Find answers, ask questions, and share your expertise

Hive set Null value to Empty string

Hive set Null value to Empty string

Contributor

Hi All,

I have Hive table with ORC format, an i have some records stored as Null in the table, is there any configuration in hive to Set Null as Empty string while Querying the data ?

Cheers,

MJ

3 REPLIES 3

Re: Hive set Null value to Empty string

Cloudera Employee

I don't think there is any such configuration. You can use CASE statement to achieve this e.g.

SELECT CASE WHEN col is NULL THEN '' ELSE col END from table;

Re: Hive set Null value to Empty string

Contributor

Hi @vgarg,

Tanx for your reply, i dont think so case statement would helpful for me, coz i need to make this change at globally across all my systems.

Cheers,

MJ

Re: Hive set Null value to Empty string

Contributor

Hi @vgarg,

Since 0.11 hive has a NVL function nvl(T value, T default_value)

which says Returns default value if value is null else returns value