1.kettle两个表做left join后数据丢失现象
表1
select customer_code,customer_name,code,pk_recitem,system,is_deleted,bill_date,prod_code,productline_code,cost from base_end2end_sale_out_cost_detail WHERE bill_date >= '${startDate}'
AND bill_date < '${finishTime}'
left join
表2
select
material_code,
customer_code,
prod_line_code,
org_name,
quantity
from (
SELECT material_code,customer_code,prod_line_code,max(org_name) org_name ,sum( quantity ) quantity
FROM base_end2end_sale_out_detail
WHERE bill_date >= '${startDate}'
AND bill_date < '${finishTime}'
and material_code is not null
and is_deleted = 0
GROUP BY material_code,customer_code,prod_line_code ) t1
where t1.quantity != 0
关联条件
code = material_code
customer_code = customer_code
2.解决方案
因为丢失的数据中关联条件相同。因此在left join 条件中增加
productline_code = prod_line_code。
最终解决该问题
3.如何提高后续查找错误的效率
1.对数据要比较清楚
最早left join前后的数据是能够对上的, 后面left join 的主表增加了一条9902654的补差数据,结果刚好久查了9902654。 如果对这个数据比较清楚,排查错误的效率肯定能够提高
2.增加可视化界面
因为测试没有啥数据,生产主要是linux的集群, 导致运行后基本看不大数据预览,排查错误比较难。后面可以弄个window的生产kettle调试用
3.一步一步的排查错误
其实可以linux的在过滤的时候少了一条数据,原则上是一条都不会少的,将这个过滤后的数据单独输出到一张表和原始数据对比,也能对比出来