如何从配置单元获取最新的分区数据

zengzsys  于 2021-06-25  发布在  Hive
关注(0)|答案(1)|浏览(404)

我需要从配置单元中具有最新分区的表中获取所有记录。这个表是按 date,year,month(date=25,year=2020,month=3) ,同样会有许多分区。
分区不是静态的,而且会经常更改。我正在尝试处理如何获取查询中的最新分区。有人能帮我写查询吗?

cs7cruho

cs7cruho1#

试试这个:

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)

同时阅读以下相关答案:
https://stackoverflow.com/a/59675908/2700344
https://stackoverflow.com/a/41952357/2700344

相关问题