一、目的
在对DWD层清洗数据进行补全后,需要生成相应的补全记录,作为数据的标记
二、实施步骤
2.1 建表
create table if not exists hurys_jw.dwd_data_correction_record(
data_type Int32 comment '数据类型 1:转向比,2:统计,3:评价,4:区域,6:静态排队,7:动态排队',
device_no String comment '设备编号',
id String comment '唯一ID',
create_time DateTime comment '创建时间',
record_type Int32 comment '记录类型 0:补全,1:修复',
day Date comment '日期'
)
ENGINE = MergeTree
PARTITION BY day
PRIMARY KEY (day,id)
ORDER BY (day,id)
SETTINGS index_granularity = 8192;
2.2 SQL语句
--1.2统计数据补全记录
select
'2' data_type,
t2.device_no,
t2.id,
t2.create_time,
'0' record_type,
cast(t2.day as String) day
from hurys_jw.dwd_statistics as t2
left join hurys_jw.ods_statistics as t3
on t3.device_no=t2.device_no and t3.create_time=t2.create_time and t3.lane_no=t2.lane_no
and t3.section_no = t2.section_no and t3.coil_no=t2.coil_no
where t2.day='2024-12-16' and length(t3.device_no)=0
;
注意红色部分,由于DWD清洗表的device_no没有设置允许非空,因此不能使用 t3.device_no is null 作为条件
2.3 Kettle任务

2.3.1 newtime

2.3.2 替换NULL值

2.3.3 clickhouse输入

2.3.4 字段选择

2.3.5 clickhouse输出

2.3.6 Kettle任务运行

搞定!