Using multiple levels of partitions in Hive

2019-07-23 07:31发布

问题:

I am wondering if the following is possible. I have data in Hive partitioned by date and logger, but I also have data that does not fall under a particular logger.

e.g.

date=2012-01-01/logger=1/part000
date=2012-01-01/logger=1/part001
date=2012-01-01/logger=2/part000
date=2012-01-01/logger=2/part001
date=2012-01-01/part000

I created my table with:

create table mytable (
    ...
)
partitioned by (date string, logger int)
....
;

and added partitions:

alter table mytable add partition (date='2012-01-01', logger=1) location '/user/me/date=2012-01-01/logger=1/';
...

I can query data in the partitions, but I cannot query data in the file date=2012-01-01/part000. Is it possible to include this file without it conforming to the partitioning?

Thank you

回答1:

Aaron, how did you manage to obtain such structure? Usually if partition key is missing HIVE creates partition called __HIVE_DEFAULT_PARTITION__.