马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
一、目标
在完成数据洗濯、错误数据之后,须要根据修复规则对错误数据举行修复
二、Hive中原有代码
- insert into table hurys_db.dwd_queue partition(day)
- select
- a3.id,
- a3.device_no,
- a3.source_device_type,
- a3.sn,
- a3.model,
- a3.create_time,
- a3.lane_no,
- a3.lane_type,
- case when a3.queue_count between 0 and 100 then a3.queue_count else a2.avg_queue_count end as queue_count,
- case when a3.queue_len between 0 and 500 then a3.queue_len else a2.avg_queue_len end as queue_len,
- case when a3.queue_head between 0 and 500 then a3.queue_head else a2.avg_queue_head end as queue_head,
- case when a3.queue_tail between 0 and 500 then a3.queue_tail else a2.avg_queue_tail end as queue_tail,
- a3.day
- from hurys_db.dwd_queue_error as a3
- right join (select
- a1.device_no,
- a1.create_time,
- a1.lane_no,
- round(avg(queue_count),0) avg_queue_count,
- round(avg(queue_len),2) avg_queue_len,
- round(avg(queue_head),2) avg_queue_head,
- round(avg(queue_tail),2) avg_queue_tail
- from(select
- t1.device_no, t1.create_time start_time, t2.create_time, t1.lane_no,
- t1.queue_count, t1.queue_len, t1.queue_head, t1.queue_tail
- from hurys_db.dwd_queue as t1
- right join hurys_db.dwd_queue_error as t2
- on t2.device_no=t1.device_no and t2.lane_no=t1.lane_no
- and concat(date_sub(t2.create_time,7),substr(t2.create_time,11,10)) = t1.create_time
- where t1.device_no is not null
- union all
- select
- t1.device_no, t1.create_time start_time, t2.create_time, t1.lane_no,
- t1.queue_count, t1.queue_len, t1.queue_head, t1.queue_tail
- from hurys_db.dwd_queue as t1
- right join hurys_db.dwd_queue_error as t2
- on t2.device_no=t1.device_no and t2.lane_no=t1.lane_no
- and concat(date_sub(t2.create_time,14),substr(t2.create_time,11,10)) = t1.create_time
- where t1.device_no is not null
- union all
- select
- t1.device_no, t1.create_time start_time, t2.create_time, t1.lane_no,
- t1.queue_count, t1.queue_len, t1.queue_head, t1.queue_tail
- from hurys_db.dwd_queue as t1
- right join hurys_db.dwd_queue_error as t2
- on t2.device_no=t1.device_no and t2.lane_no=t1.lane_no
- and concat(date_sub(t2.create_time,21),substr(t2.create_time,11,10)) = t1.cr
复制代码 |