メインコンテンツまでスキップ
バージョン: 4.x

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 |
+-------------+