How to find the most recent partition in HIVE table

后端 未结 4 1130
清酒与你
清酒与你 2020-12-31 05:41

I have a partitioned table - with 201 partitions. I need to find latest partition in this table and use it to post process my data. The query to find list of all partitions

4条回答
  •  佛祖请我去吃肉
    2020-12-31 06:10

    If you want to avoid running the "show partitions" in hive shell as suggested above, you can apply a filter to your max() query. That will avoid doing a fulltable scan and results should be fairly quick!

    select max(ingest_date) from db.table_name where ingest_date>date_add(current_date,-3) will only scan 2-3 partitions.

提交回复
热议问题