string類型的' '(空字符),hive底層中存儲為' '
int/string類型的null,底層存儲為\N,盡管這樣做會占據較多資源,但是卻方便了插入空值數據的操作(提前占位)
對於null的提取:is null // is not null // coalesce(null,'')
對於' '的提取:
1)修改已有表:alter table test_01 set serdeproperties('serialization.null.format'='')在底層存儲中,使' '和null等價,null存儲展示為' ',查詢結果展示為null,這時同樣用is null // is not null查詢
2)建表時指定:
eg1.
ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
with serdeproperties('serialization.null.format' = '')
eg2.
ROW FORMAT DELIMITED NULL DEFINED AS ''
3)個人認為這是最為方便的
如存在以下數據,第一行無數據的數據類型是string的' '

通過下述操作,即可剔除' '的行
select col1,col2,col3,col4
from table_name
where col2>'0' ##(只要不是=' ',>' '也行,提示:與ascii碼有關)
參考來源:
