hiveql - In Hive, How to select only values of one of the dynamic partitions (when there are one or more partitions available) -
now have table has structure follows,
hive> desc clicks_fact; ok time timestamp .. day date file_date varchar(8) # partition information # col_name data_type comment day date file_date varchar(8) time taken: 1.075 seconds, fetched: 28 row(s)
now want partitions of table.
hive> show partitions clicks_fact; ok day=2016-09-02/file_date=20160902 .. day=2017-06-30/file_date=20170629 time taken: 0.144 seconds, fetched: 27 row(s)
i partitions combination of both day & file_date
. now, there way values of file_date
hive offers limited options metadata retrieval.
query metastore directly.
demo
hive
create table clicks_fact (i int) partitioned (day date,file_date int) ; alter table clicks_fact add partition (day=date '2016-09-02',file_date=20160901) partition (day=date '2016-09-02',file_date=20160902) partition (day=date '2016-09-03',file_date=20160901) partition (day=date '2016-09-03',file_date=20160902) partition (day=date '2016-09-03',file_date=20160903) ;
metastore (mysql)
use metastore; select distinct pkv.part_key_val dbs d join tbls t on t.db_id = d.db_id join partition_keys pk on pk.tbl_id = t.tbl_id join partitions p on p.tbl_id = t.tbl_id join partition_key_vals pkv on pkv.part_id = p.part_id , pkv.integer_idx = pk.integer_idx d.name = 'local_db' , t.tbl_name = 'clicks_fact' , pk.pkey_name = 'file_date' ;
+--------------+ | part_key_val | +--------------+ | 20160901 | | 20160902 | | 20160903 | +--------------+
Comments
Post a Comment