Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

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
Highlighted

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;
Highlighted

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

Highlighted

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

Don't have an account?
Coming from Hortonworks? Activate your account here