所以需要通过serialization.null.format的设置来修改表的默认的null表示方式。
测试表
hive> select * from sunwg00;
OK
NULL mary
101 tom
Time taken: 0.058 seconds
创建普通表sunwg01,没有指定serialization.null.format
hive> CREATE TABLE sunwg01 (id int,name STRING) STORED AS TEXTFILE;
OK
Time taken: 0.04 seconds
hive> insert overwrite table sunwg01 select * from sunwg00;
Loading data to table sunwg01
2 Rows loaded to sunwg01
OK
Time taken: 17.047 seconds
查看sunwg01在hdfs的文件
[hjl@sunwg src]$ hadoop fs -cat /hjl/sunwg01/attempt_201105020924_0011_m_000000_0
/Nmary
101tom
NULL值被转写成’/N’
创建表sunwg02,指定serialization.null.format
hive> CREATE TABLE sunwg02 (id int,name STRING)
> ROW FORMAT SERDE ‘org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe’
> WITH SERDEPROPERTIES (
> ‘field.delim’='/t’,
> ‘escape.delim’='//’,
> ‘serialization.null.format’=”
> ) STORED AS TEXTFILE;
OK
Time taken: 0.046 seconds
hive> insert overwrite table sunwg02 select * from sunwg00;
Loading data to table sunwg02
2 Rows loaded to sunwg02
OK
Time taken: 18.756 seconds
查看sunwg02在hdfs的文件
[hjl@sunwg src]$ hadoop fs -cat /hjl/sunwg02/attempt_201105020924_0013_m_000000_0
mary
101 tom
NULL值没有被转写成’/N’,而是空字符串。