Hive describe partitions to show partition url

2019-04-26 12:26发布

问题:

I know that there is

decribe formatted table_name;

that shows you the table format. Is there a way to get a more information about partitions apart from

show partitions table_name;

I saw that Hive language manual has this

DESCRIBE [EXTENDED|FORMATTED] [db_name.]table_name PARTITION partition_spec

I would like to view all the partitions along with the url in hdfs or s3 where the data is stored.

回答1:

To show partitions:

show partitions table_name

To show where a partition is physically stored:

describe formatted dbname.tablename partition (name=value)

I don't know of a built-in way to create an output that is (partition, path) but you can build it using these two commands and some grep/awk or whatever.



回答2:

analyze table TABLENAME partition(the_partition) compute statistics nopass;

The above code gives you more info about the partitions (number of files, number of rows, total size), but doesn't give you exact location.

If you want exact location, you may want to create an external table.