如何从配置单元获取最新的分区数据 [英] How to getting latest partition data from hive
本文介绍了如何从配置单元获取最新的分区数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要从具有最新分区的配置单元中的表中获取所有记录.该表由date,year,month
分区,例如(date=25,year=2020,month=3)
,同样会有很多分区.
I need to fetch all records from a table in hive which is having latest partitions. The table is partitioned by date,year,month
eg (date=25,year=2020,month=3)
, likewise there will be many partitions.
分区不是静态的,它将经常更改.我正在尝试获取查询中的最新分区. 有人可以帮我写查询吗?
The partitions are not static and it will be changing frequently. I am trying to handle of getting the latest partition in the query. Can anybody help me to write the query?
推荐答案
尝试一下:
select *
from your_table t
where concat_ws('-',t.year,t.month,t.date) in (select max(concat_ws('-',s.year,s.month,s.date)) from your_table s)
也请阅读以下相关答案:
Also read these related answers:
https://stackoverflow.com/a/59675908/2700344
https://stackoverflow.com/a/41952357/2700344
这篇关于如何从配置单元获取最新的分区数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文