hive 空值、NULL判斷

hive中空值判斷基本分兩種spa

(1)NULL 與 \Norm

hive在底層數據中如何保存和標識NULL,是由 alter table name SET SERDEPROPERTIES('serialization.null.format' = '\N'); 參數控制的字符串

好比:it

1.設置 alter table name SET SERDEPROPERTIES('serialization.null.format' = '\N'); io

則:底層數據保存的是'\N',經過查詢顯示的是'NULL'table

這時若是查詢爲空值的字段可經過 語句:a is null 或者 a='\\N'form

 

          2.設置 alter tablename SET SERDEPROPERTIES('serialization.null.format' = 'NULL'); 數據

則:底層數據保存的是'NULL',經過查詢顯示的是'NULL'查詢

這時若是查詢爲空值的字段可經過 語句:a is null 或者 a='NULL'tab

(2)'' 與 length(xx)=0

'' 表示的是字段不爲null且爲空字符串,此時用 a is null 是沒法查詢這種值的,必須經過 a=''  或者 length(a)=0 查詢 ,不等於能夠用 a=<>'' 

相關文章
相關標籤/搜索