SHOW PARTITIONS
Lists all the partitions in an Athena table in unsorted order.
Synopsis
SHOW PARTITIONS table_name
-
To show the partitions in a table and list them in a specific order, see the List partitions for a specific table section on the Query the AWS Glue Data Catalog page.
-
To view the contents of a partition, see the Query the data section on the Partition your data page.
-
SHOW PARTITIONS
does not list partitions that are projected by Athena but not registered in the AWS Glue catalog. For information about partition projection, see Use partition projection with Amazon Athena. -
SHOW PARTITIONS
lists the partitions in metadata, not the partitions in the actual file system. To update the metadata after you delete partitions manually in Amazon S3, run ALTER TABLE DROP PARTITION.
Examples
The following example query shows the partitions for the
flight_delays_csv
table, which shows flight table data from the US
Department of Transportation. For more information about the example
flight_delays_csv
table, see Lazy Simple SerDe for CSV, TSV, and custom-delimited
files. The table is partitioned by year.
SHOW PARTITIONS flight_delays_csv
Results
year=2007 year=2015 year=1999 year=1993 year=1991 year=2003 year=1996 year=2014 year=2004 year=2011 ...
The following example query shows the partitions for the impressions
table, which contains sample web browsing data. For more information about the example
impressions
table, see Partition your data. The table is partitioned by the dt
(datetime) column.
SHOW PARTITIONS impressions
Results
dt=2009-04-12-16-00 dt=2009-04-13-18-15 dt=2009-04-14-00-20 dt=2009-04-12-13-00 dt=2009-04-13-02-15 dt=2009-04-14-12-05 dt=2009-04-14-06-15 dt=2009-04-12-21-15 dt=2009-04-13-22-15 ...
Listing partitions in sorted order
To order the partitions in the results list, use the following SELECT
syntax instead of SHOW PARTITIONS
.
SELECT * FROM
database_name
."table_name
$partitions" ORDER BYcolumn_name
The following query shows the list of partitions for the
flight_delays_csv
example, but in sorted order.
SELECT * FROM "flight_delays_csv$partitions" ORDER BY year
Results
year 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 ...
For more information, see the List partitions for a specific table section on the Query the AWS Glue Data Catalog page.