hive數據落地到hdfs,null會默認用'\N'存儲
解決方式1:利用命令(這個我沒起效果)
alter table adl_cici_test_fdt set serdeproperties('serialization.null.format' = '');
解決方式2;建表時直接指定(兩種方式)
a、用語句
ROW FORMAT SERDE ‘org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe’
with serdeproperties('serialization.null.format' = '')
實現,注意兩者必須一起使用,如
CREATETABLE hive_tb (idint,name STRING)
PARTITIONED BY (`day` string,`type` tinyint COMMENT'0 as bid, 1 as win, 2 as ck',`hour` tinyint)
ROW FORMAT SERDE ‘org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe’
WITH SERDEPROPERTIES (‘field.delim’='/t’,‘escape.delim’='//’,serialization.null.format'='' )
STORED AS TEXTFILE;
b、或者通過
ROW FORMAT DELIMITED NULL DEFINED AS ''
CREATETABLE hive_tb (idint,name STRING) PARTITIONED BY (`day` string,`type` tinyint COMMENT'0 as bid, 1 as win, 2 as ck',`hour` tinyint) ROW FORMAT DELIMITED NULL DEFINED AS '' STORED AS TEXTFILE;
如:
create table vip_info( id string, mobile string)row format delimited fields terminated by '\t' NULL DEFINED AS '' stored as textfile;
解決方式3:
insert overwrite directory 'hive_test/vip' ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe' WITH SERDEPROPERTIES ( 'field.delim'='\t', 'serialization.format'= '', 'serialization.null.format'='' ) STORED AS TEXTFILE select * from user;