蜂巢 - 没有保留空字符串

问题描述 投票:0回答:2

当我在tableA中插入包含空字符串的数据,然后执行

select * from tableA;

我看到空字符串被NULL值替换。

如何保留空字符串值而不是NULL值?

string hive null is-empty
2个回答
0
投票

你应该得到空字符串不为空。

hive> create temporary table t1 as select '' as c1, 
' ' as c2; --- ' ' space
Time taken: 0.145 seconds, Fetched: 1 row(s)
hive> select concat('|',c1, '|', c2, '|') from t1;
OK
|| |
Time taken: 0.319 seconds, Fetched: 1 row(s)

hive> insert into t1 values ('  ', '   '); -- multiple spaces
Time taken: 13.6 seconds
hive> select concat('|',c1, '|', c2, '|') from t1;
OK
|| |
|  |   |
Time taken: 0.136 seconds, Fetched: 2 row(s)

0
投票

刚发现它...原因是当插入在一个需要字符串的字段中使用空值完成时,则保留空值,但是当字段需要字符串以外的其他内容时,例如,如果字段需要接收一个整数,然后将空值作为NULL值插入。

© www.soinside.com 2019 - 2024. All rights reserved.