Null value judgment in hive

 
There are basically two types of judgments for null values ​​in hive
(1) NULL and \N
How hive saves and identifies NULL in the underlying data is controlled by the parameter alter table name SET SERDEPROPERTIES('serialization.null.format' = '\N');
for example:
1.设置 alter table  name  SET SERDEPROPERTIES( 'serialization.null.format' = '\N' ); 
Then: the underlying data is saved as '\N', and the query displays 'NULL'
At this time, if you query the field with a null value, you can pass the statement: a is null or a='\\N'
 
          2.设置 alter table name  SET SERDEPROPERTIES( 'serialization.null.format' = 'NULL' ); 
Then: the underlying data is 'NULL', and the query displays 'NULL'
At this time, if you query the field with a null value, you can pass the statement: a is null or a='NULL'
(2)'' 与 length(xx)=0
'' means that the field is not null and is an empty string. At this time, it is impossible to query this value with a is null. It must be queried by  a   =''   or  length(a)=0

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326737993&siteId=291194637