hive的使用中不可避免对null、‘’的判断识别。但是hive区别与传统的数据库。下面一一说明 1、数据类型: int与string的存储。null默认的存储都是\N。 string的数据如果为""。存储才是""。另外往int类型的字段插入数据“”.结果还是\N [hadoop@nn1 ~]$ hadoop fs -cat /user/hive/warehouse/aaa.db/dual2/* Warning: $HADOOP_HOME is deprecated. 1aaa \Nbbb 3\N 3 4 2、查询的时候: 对于int就是可以使用is null。 对于string类型,is null 查出来的是\N的数据;对于条件 ='',查询出来的数据是""的。 select b.id,b.name,a.id from dual2 b left outer join dual a on (a.id=b.id) where b.name =''; 结果: 3 NULL 4 NULL select b.id,b.name,a.id from dual2 b left outer join dual a on (a.id=b.id) where b.name is null; 结果: 3 NULL NULL 可以看出:判断是根据实际的存储判断所得出。 因此,在开发过程中如果需要对空进行判断,一定得知道存储的是哪种数据。