在hive数据清洗这里总结三种常用的去重方式

1.distinct

2.group by

3.row_number()

实例:

SELECT tel, link_name, certificate_no, certificate_type, modify_time
  FROM order_info
 WHERE deleted = 'F'
   AND pay_status = 'payed'
   AND create_time >= to_date('2017-04-23', 'yyyy-MM-dd')
   AND create_time < to_date('2017-04-24', 'yyyy-MM-dd')
   AND row_number() over(PARTITION BY tel ORDER BY tel DESC) = 1

上面SQL对某一字段(tel)排序后分区去重,这样避免了其对不相干字段的数据干扰,影响数据处理的效率

推荐方法三

Logo

欢迎加入DeepSeek 技术社区。在这里,你可以找到志同道合的朋友,共同探索AI技术的奥秘。

更多推荐