Skip to main content

SHOW PARTITIONS

Descriptions​

This statement is used to display partition information. It supports both Internal catalog and Hive Catalog.

For Hive Catalog:

It supports returning all partitions, including multi-level partitions.

Syntax​

SHOW [ TEMPORARY ] PARTITIONS
FROM [ <db_name>. ] <table_name>
[ <where_clause> ]
[ ORDER BY <order_by_key> ]
[ LIMIT <limit_rows> ];

Required Parameters​

1. <table_name>

The name of the table for which partition information needs to be viewed must be specified.

Optional Parameters​

1. TEMPORARY

Whether to query the information of temporary partitions.

2. <db_name>

The name of the database for which partition information needs to be viewed must be specified.

3. <where_clause>

Filter conditions, supporting filtering on columns such as PartitionId, PartitionName, State, Buckets, ReplicationNum, LastConsistencyCheckTime, etc.

Please note that:

  1. Currently, the where clause only supports the = operator and does not support operators such as >, <, >=, <=, etc.
  2. When using the = operator in the where clause, the column name needs to be on the left side.

4. <order_by_key>

Sorting conditions, supporting sorting on columns such as PartitionId, PartitionName, State, Buckets, ReplicationNum, LastConsistencyCheckTime, etc.

5. <limit_rows>

The maximum number of rows returned.

Return Value​

ColumnsDataTypeNote
PartitionIdbigintPartition ID
PartitionNamevarcharPartition Name
VisibleVersionintThe maximum VisibleVersion of the tablets in this partition.
VisibleVersionTimedatetimeThe time of the most recent VisibleVersion in this partition.
StatevarcharThe State of this partition
PartitionKeydatetimeThe partition key of this partition
RangedatetimeThe Range of this partition
DistributionKeyvarcharThe distribution key of this partition
BucketsintThe bucket num of this partition
ReplicationNumintThe replica num of this partition
StorageMediumvarcharThe storage medium of this partition
CooldownTimedatetimeThe cooldown time of this partition. If there is no hot-cold separation, the value of this field is [9999-12-31 23:59:59], which means it is always hot data.
RemoteStoragePolicyvarcharThe remote storage policy of this partition.
LastConsistencyCheckTimedatetimeThe time of the last partition consistency check for this partition.
DataSizeintThe data size under this partition.
IsInMemorybooleanWhether it is an in-memory partition, the default is false.
ReplicaAllocationvarcharThe replica distribution strategy of this partition.
IsMutablebooleanWhether the partition is mutable, the default is true.
SyncWithBaseTablesbooleanWhether the partition is synchronized with the data of the base table.
UnsyncTablesvarcharWhether the partition is a partition of an unsynchronized table.

Access Control Requirements​

The SHOW permission for the table to be viewed is required.

Examples​

  1. Show all non-temporary partition information for a specified table in a specified database.
SHOW PARTITIONS FROM t_agg;
+-------------+---------------+----------------+---------------------+--------+--------------+-------+-----------------+---------+----------------+---------------+---------------------+---------------------+--------------------------+-----------+------------+-------------------------+-----------+--------------------+--------------+
| PartitionId | PartitionName | VisibleVersion | VisibleVersionTime | State | PartitionKey | Range | DistributionKey | Buckets | ReplicationNum | StorageMedium | CooldownTime | RemoteStoragePolicy | LastConsistencyCheckTime | DataSize | IsInMemory | ReplicaAllocation | IsMutable | SyncWithBaseTables | UnsyncTables |
+-------------+---------------+----------------+---------------------+--------+--------------+-------+-----------------+---------+----------------+---------------+---------------------+---------------------+--------------------------+-----------+------------+-------------------------+-----------+--------------------+--------------+
| 170307 | t_agg | 4 | 2024-11-05 16:13:40 | NORMAL | | | k1 | 1 | 1 | HDD | 9999-12-31 23:59:59 | | NULL | 806.000 B | false | tag.location.default: 1 | true | true | NULL |
+-------------+---------------+----------------+---------------------+--------+--------------+-------+-----------------+---------+----------------+---------------+---------------------+---------------------+--------------------------+-----------+------------+-------------------------+-----------+--------------------+--------------+
  1. Show all temporary partition information for a specified table in a specified database.
SHOW TEMPORARY PARTITIONS FROM t_temp;
+-------------+---------------+----------------+---------------------+--------+--------------+----------------------------------------------------------------------------------------------------------+-----------------+---------+----------------+---------------+---------------------+---------------------+--------------------------+----------+------------+-------------------------+-----------+--------------------+--------------+
| PartitionId | PartitionName | VisibleVersion | VisibleVersionTime | State | PartitionKey | Range | DistributionKey | Buckets | ReplicationNum | StorageMedium | CooldownTime | RemoteStoragePolicy | LastConsistencyCheckTime | DataSize | IsInMemory | ReplicaAllocation | IsMutable | SyncWithBaseTables | UnsyncTables |
+-------------+---------------+----------------+---------------------+--------+--------------+----------------------------------------------------------------------------------------------------------+-----------------+---------+----------------+---------------+---------------------+---------------------+--------------------------+----------+------------+-------------------------+-----------+--------------------+--------------+
| 828863 | tp2020 | 1 | 2025-01-22 16:19:50 | NORMAL | create_time | [types: [DATETIMEV2]; keys: [2020-01-01 00:00:00]; ..types: [DATETIMEV2]; keys: [2021-01-01 00:00:00]; ) | reference_no | 1 | 1 | SSD | 9999-12-31 23:59:59 | | NULL | 0.000 | false | tag.location.default: 1 | true | true | NULL |
+-------------+---------------+----------------+---------------------+--------+--------------+----------------------------------------------------------------------------------------------------------+-----------------+---------+----------------+---------------+---------------------+---------------------+--------------------------+----------+------------+-------------------------+-----------+--------------------+--------------+
  1. Show the information of a specified non-temporary partition for a specified table in a specified database, and filter the results.
SHOW PARTITIONS FROM t_agg WHERE PartitionName = "p2024";
+-------------+---------------+----------------+---------------------+--------+-----------------+----------------------------------------------------------------------------------------------------------+-----------------+---------+----------------+---------------+---------------------+---------------------+--------------------------+-----------+------------+-------------------------+-----------+--------------------+--------------+
| PartitionId | PartitionName | VisibleVersion | VisibleVersionTime | State | PartitionKey | Range | DistributionKey | Buckets | ReplicationNum | StorageMedium | CooldownTime | RemoteStoragePolicy | LastConsistencyCheckTime | DataSize | IsInMemory | ReplicaAllocation | IsMutable | SyncWithBaseTables | UnsyncTables |
+-------------+---------------+----------------+---------------------+--------+-----------------+----------------------------------------------------------------------------------------------------------+-----------------+---------+----------------+---------------+---------------------+---------------------+--------------------------+-----------+------------+-------------------------+-----------+--------------------+--------------+
| 169851 | p2024 | 2 | 2024-11-05 14:14:29 | NORMAL | idp_create_time | [types: [DATETIMEV2]; keys: [2024-01-01 00:00:00]; ..types: [DATETIMEV2]; keys: [2025-01-01 00:00:00]; ) | idp_es_id | 3 | 1 | HDD | 9999-12-31 23:59:59 | | NULL | 27.396 KB | false | tag.location.default: 1 | true | true | NULL |
+-------------+---------------+----------------+---------------------+--------+-----------------+----------------------------------------------------------------------------------------------------------+-----------------+---------+----------------+---------------+---------------------+---------------------+--------------------------+-----------+------------+-------------------------+-----------+--------------------+--------------+
  1. Show the information of the latest non-temporary partition for a specified table in a specified database.
SHOW PARTITIONS FROM t_agg ORDER BY PartitionId DESC LIMIT 1;
+-------------+---------------+----------------+---------------------+--------+-----------------+----------------------------------------------------------------------------------------------------------+-----------------+---------+----------------+---------------+---------------------+---------------------+--------------------------+----------+------------+-------------------------+-----------+--------------------+--------------+
| PartitionId | PartitionName | VisibleVersion | VisibleVersionTime | State | PartitionKey | Range | DistributionKey | Buckets | ReplicationNum | StorageMedium | CooldownTime | RemoteStoragePolicy | LastConsistencyCheckTime | DataSize | IsInMemory | ReplicaAllocation | IsMutable | SyncWithBaseTables | UnsyncTables |
+-------------+---------------+----------------+---------------------+--------+-----------------+----------------------------------------------------------------------------------------------------------+-----------------+---------+----------------+---------------+---------------------+---------------------+--------------------------+----------+------------+-------------------------+-----------+--------------------+--------------+
| 169866 | p2025 | 1 | 2024-11-05 14:13:56 | NORMAL | idp_create_time | [types: [DATETIMEV2]; keys: [2025-01-01 00:00:00]; ..types: [DATETIMEV2]; keys: [2026-01-01 00:00:00]; ) | idp_es_id | 3 | 1 | HDD | 9999-12-31 23:59:59 | | NULL | 0.000 | false | tag.location.default: 1 | true | true | NULL |
+-------------+---------------+----------------+---------------------+--------+-----------------+----------------------------------------------------------------------------------------------------------+-----------------+---------+----------------+---------------+---------------------+---------------------+--------------------------+----------+------------+-------------------------+-----------+--------------------+--------------+