NULL data is converted to '\ n' for numeric columns in the hive.?

I have created a hive table that has numeric columns like double and string columns. My file contains some NULL values ​​for numeric and string columns. When I try to load a file into this table, NULL values ​​for numeric columns are replaced with "\ n" in the file. I know it is a hive property that handles null values ​​for numeric columns, but I want to prevent this or is there any way I can change NULL to something else instead of '\ n'.

+3


source to share


1 answer


By default, values ​​are NULL

written to data files because they are \N

also \N

interpreted in data files as NULL

when querying data.
This can be overridden usingTBLPROPERTIES('serialization.null.format'=...)

eg.
TBLPROPERTIES('serialization.null.format'='')

means the following:

  • Empty field in data files will be treated as NULL when querying the table
  • When inserting rows into a table, NULL values ​​will be written to data files as empty fields



This property can be declared as part of the table creation

create table mytable (...)
tblproperties('serialization.null.format'='')
;

      

and can be changed later

alter table mytable set tblproperties('serialization.null.format'='')
;

      

+8


source







All Articles