dataX同步失败
报错信息:

检查完后发现hdfs中产生了空文件
空文件产生原因
情况:一个有数据文件,一个空文件

SQL语句
insert overwrite table demo.student partition (dt=10)
select id, name, age, score, lng, flt, dbl, str from demo.student where dt={dt}
原因:
1 . 分区没有数据
2.insert overwrite 语句指定了partition值,执行器会先创建分区,最后创建空白数据文件或只有表结构schema的文件。
解决:
1. 确保分区有数据
2. 使用动态分区,不在insert overwrite 指定partition值,将partition值作为select 字段之一
-- 开启动态分区支持(默认 true)
SET hive.exec.dynamic.partition=true;
-- 是否允许所有分区都是动态的,strict 要求至少包含一个静态分区列,nonstrict 则无此要求(默认 strict)
SET hive.exec.dynamic.partition.mode=nonstrict;
修改后
insert overwrite table demo.student partition (dt=10)
select id, name, age, score, lng, flt, dbl, str,dt from demo.student where dt={dt}
Asia/Shanghai时区
做数据迁移时,按时间戳进行分区时,通过hiveSQL普通时间戳转换,会用八个小时的时差,会导致存储数据的时间问题,所以需要使用Asia/Shanghai时区
SELECT
date_format(from_utc_timestamp(from_unixtime(cast((cast(datastatisticsendtime as bigint) - 86400000) / 1000 as bigint)), 'Asia/Shanghai'),'yyyyMMdd') AS specified_timezone,createtime
FROM default.a;
1802

被折叠的 条评论
为什么被折叠?



