Sqoop
--null-string '' \
--null-non-string '' \
Hive
Method 1:
alter table ... set serdeproperties ('serialization.null.format' = "");
Method 2:
TBLPROPERTIES('serialization.null.format' = "") ;
Test examples
drop table if exists test;
CREATE EXTERNAL TABLE test (
uuid string,
user_id bigint
)
row format delimited fields terminated by '\t'
LOCATION '/AidenSun/test'
TBLPROPERTIES('serialization.null.format' = "") ;
insert into test values("1","");
hive> select * from test;
OK
1 NULL
select coalesce(user_id,uuid) as user_id from test;
Files in HDFS:
Spark
如果上面的hive表是parquet表,必须确保dataframe不会产生新的“” ,否则hive上述设置失效。
[WARN]Reprinted without permission is prohibited.未经授权禁止转载