【发布时间】:2020-07-21 01:24:17
【问题描述】:
我对下面语句的理解是,如果在hive列中插入空白或空字符串,则将其视为null。
TBLPROPERTIES('serialization.null.format'=''
为了测试功能,我创建了一个表并在字段 3 中插入了“”。当我在字段 3 上查询空值时,没有符合该条件的行。
我对使空白字符串为空的理解正确吗??
CREATE TABLE CDR
(
field1 string,
field2 string,
field3 string
)
ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n'
**TBLPROPERTIES('serialization.null.format'='');**
insert overwrite table emmtest.cdr select **field1,field2,''** from emmtest.cdr_non_orc;
select * from emmtest.cdr where **field3 is null;**
最后一条语句没有返回任何行。但我希望返回所有行,因为 field3 中有空白字符串。
【问题讨论】:
-
空字符串永远不会等于 null。
field3=''将返回这些行。 -
如何在 Hive 中将空字符串设为 null?这个参数是什么意思? - TBLPROPERTIES('serialization.null.format'='')