メインコンテンツまでスキップ
に最終更新

PARTITIONS

説明​

このテーブル関数は一時的なパーティションテーブルを生成し、指定したテーブルのパーティション一覧を参照できるようにします。

構文​

PARTITIONS(
"catalog"="<catalog>",
"database"="<database>",
"table"="<table>"
)

必須パラメータ​

項目説明
<catalog>照会するクラスタのカタログ名を指定します。
<database>照会するクラスタのデータベース名を指定します。
<table>照会するクラスタのテーブル名を指定します。

戻り値​

項目説明
PartitionIdパーティション ID
PartitionNameパーティション名
VisibleVersionパーティションのバージョン
VisibleVersionTimeパーティションのバージョンがコミットされた時刻
Stateパーティションの状態
PartitionKeyパーティションキー
Rangeパーティションの範囲
DistributionKeyパーティション分散キー
Bucketsパーティション内のバケット数
ReplicationNumパーティション内のレプリカ数
StorageMediumパーティションに使用されるストレージメディア
CooldownTimeパーティションのクールダウン時刻
RemoteStoragePolicyパーティションのリモートストレージポリシー
LastConsistencyCheckTimeパーティションの最終整合性チェック時刻
DataSizeパーティション内のデータサイズ
IsInMemoryパーティションがメモリに格納されているかどうか
ReplicaAllocationパーティションのレプリカ配置方針
IsMutableパーティションが変更可能かどうか
SyncWithBaseTablesパーティションがベーステーブルと同期しているかどうか(非同期マテリアライズドビュー用)
UnsyncTables同期していないベーステーブル(非同期マテリアライズドビューのパーティション用)

例​

internal カタログの test データベースにある example_table のパーティション一覧を表示します。

select * from partitions("catalog"="internal","database"="test","table"="example_table");
+-------------+---------------+----------------+---------------------+--------+--------------+--------------------------------------------------------------------------------+-----------------+---------+----------------+---------------+---------------------+---------------------+--------------------------+----------+------------+-------------------------+-----------+--------------------+--------------+
| PartitionId | PartitionName | VisibleVersion | VisibleVersionTime | State | PartitionKey | Range | DistributionKey | Buckets | ReplicationNum | StorageMedium | CooldownTime | RemoteStoragePolicy | LastConsistencyCheckTime | DataSize | IsInMemory | ReplicaAllocation | IsMutable | SyncWithBaseTables | UnsyncTables |
+-------------+---------------+----------------+---------------------+--------+--------------+--------------------------------------------------------------------------------+-----------------+---------+----------------+---------------+---------------------+---------------------+--------------------------+----------+------------+-------------------------+-----------+--------------------+--------------+
| 43209 | p1 | 1 | 2025-01-17 12:35:22 | NORMAL | created_at | [types: [DATEV2]; keys: [0000-01-01]; ..types: [DATEV2]; keys: [2023-01-01]; ) | id | 10 | 1 | HDD | 9999-12-31 23:59:59 | | \N | 0.000 | 0 | tag.location.default: 1 | 1 | 1 | \N |
| 43210 | p2 | 1 | 2025-01-17 12:35:22 | NORMAL | created_at | [types: [DATEV2]; keys: [2023-01-01]; ..types: [DATEV2]; keys: [2024-01-01]; ) | id | 10 | 1 | HDD | 9999-12-31 23:59:59 | | \N | 0.000 | 0 | tag.location.default: 1 | 1 | 1 | \N |
| 43211 | p3 | 1 | 2025-01-17 12:35:22 | NORMAL | created_at | [types: [DATEV2]; keys: [2024-01-01]; ..types: [DATEV2]; keys: [2025-01-01]; ) | id | 10 | 1 | HDD | 9999-12-31 23:59:59 | | \N | 0.000 | 0 | tag.location.default: 1 | 1 | 1 | \N |
| 43212 | p4 | 1 | 2025-01-17 12:35:22 | NORMAL | created_at | [types: [DATEV2]; keys: [2025-01-01]; ..types: [DATEV2]; keys: [2026-01-01]; ) | id | 10 | 1 | HDD | 9999-12-31 23:59:59 | | \N | 0.000 | 0 | tag.location.default: 1 | 1 | 1 | \N |
+-------------+---------------+----------------+---------------------+--------+--------------+--------------------------------------------------------------------------------+-----------------+---------+----------------+---------------+---------------------+---------------------+--------------------------+----------+------------+-------------------------+-----------+--------------------+--------------+

example_table のうち、パーティション名が p1 のパーティション情報を表示します。

select * from partitions("catalog"="internal","database"="test","table"="example_table") where PartitionName = "p1";
+-------------+---------------+----------------+---------------------+--------+--------------+--------------------------------------------------------------------------------+-----------------+---------+----------------+---------------+---------------------+---------------------+--------------------------+----------+------------+-------------------------+-----------+--------------------+--------------+
| PartitionId | PartitionName | VisibleVersion | VisibleVersionTime | State | PartitionKey | Range | DistributionKey | Buckets | ReplicationNum | StorageMedium | CooldownTime | RemoteStoragePolicy | LastConsistencyCheckTime | DataSize | IsInMemory | ReplicaAllocation | IsMutable | SyncWithBaseTables | UnsyncTables |
+-------------+---------------+----------------+---------------------+--------+--------------+--------------------------------------------------------------------------------+-----------------+---------+----------------+---------------+---------------------+---------------------+--------------------------+----------+------------+-------------------------+-----------+--------------------+--------------+
| 43209 | p1 | 1 | 2025-01-17 12:35:22 | NORMAL | created_at | [types: [DATEV2]; keys: [0000-01-01]; ..types: [DATEV2]; keys: [2023-01-01]; ) | id | 10 | 1 | HDD | 9999-12-31 23:59:59 | | \N | 0.000 | 0 | tag.location.default: 1 | 1 | 1 | \N |
+-------------+---------------+----------------+---------------------+--------+--------------+--------------------------------------------------------------------------------+-----------------+---------+----------------+---------------+---------------------+---------------------+--------------------------+----------+------------+-------------------------+-----------+--------------------+--------------+

example_table のうち、パーティション名が p1 のパーティション ID を表示します。

select PartitionId from partitions("catalog"="internal","database"="test","table"="example_table") where PartitionName = "p1";
+-------------+
| PartitionId |
+-------------+
| 43209 |
+-------------+