に最終更新
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 |
+-------------+