PARTITIONS
説明
table関数は一時的なパーティションTABLEを生成し、特定のTABLEのPARTITIONリストを表示することができます。
構文
PARTITIONS(
"catalog"="<catalog>",
"database"="<database>",
"table"="<table>"
)
必須パラメータ
| Field | デスクリプション |
|---|---|
<catalog> | クエリ対象のクラスターカタログ名を指定します。 |
<database> | クエリ対象のクラスターデータベース名を指定します。 |
<table> | クエリ対象のクラスターTable名を指定します。 |
戻り値
| Field | デスクリプション |
|---|---|
| PartitionId | パーティションID |
| PartitionName | パーティション名 |
| VisibleVersion | パーティションバージョン |
| VisibleVersionTime | パーティションバージョンがコミットされた時刻 |
| State | パーティションの状態 |
| PartitionKey | パーティションキー |
| Range | パーティションの範囲 |
| DistributionKey | パーティショニング用の分散キー |
| Buckets | パーティション内のバケット数 |
| ReplicationNum | パーティション内のレプリカ数 |
| StorageMedium | パーティションに使用されるストレージメディア |
| CooldownTime | パーティションのクールダウン時間 |
| RemoteStoragePolicy | パーティションのリモートストレージポリシー |
| LastConsistencyCheckTime | パーティションの最後の整合性チェックの時刻 |
| DataSize | パーティション内のデータサイズ |
| IsInMemory | パーティションがメモリに格納されているかどうか |
| ReplicaAllocation | パーティションのレプリケーション戦略 |
| IsMutable | パーティションが可変かどうか |
| SyncWithBaseTables | パーティションがベースTableと同期されているかどうか(非同期マテリアライズドビュー用) |
| UnsyncTables | どのベースTableが非同期か(非同期マテリアライズドビューパーティション用) |
例
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 |
+-------------+