メインコンテンツまでスキップ
メインコンテンツまでスキップ

mergeTreeProjection テーブル関数

MergeTree テーブルにおけるプロジェクションの内容を表します。内部的な解析に使用できます。

構文

mergeTreeProjection(database, table, projection)

引数

引数説明
databaseプロジェクションを読み取るデータベース名。
tableプロジェクションを読み取るテーブル名。
projection読み取るプロジェクション。

戻り値

指定されたプロジェクションによって提供されるカラムを持つテーブルオブジェクト。

使用例

CREATE TABLE test
(
    `user_id` UInt64,
    `item_id` UInt64,
    PROJECTION order_by_item_id
    (
        SELECT _part_offset
        ORDER BY item_id
    )
)
ENGINE = MergeTree
ORDER BY user_id;

INSERT INTO test SELECT number, 100 - number FROM numbers(5);
SELECT *, _part_offset FROM mergeTreeProjection(currentDatabase(), test, order_by_item_id);
   ┌─item_id─┬─_parent_part_offset─┬─_part_offset─┐
1. │      96 │                   4 │            0 │
2. │      97 │                   3 │            1 │
3. │      98 │                   2 │            2 │
4. │      99 │                   1 │            3 │
5. │     100 │                   0 │            4 │
   └─────────┴─────────────────────┴──────────────┘
DESCRIBE mergeTreeProjection(currentDatabase(), test, order_by_item_id) SETTINGS describe_compact_output = 1;
   ┌─name────────────────┬─type───┐
1. │ item_id             │ UInt64 │
2. │ _parent_part_offset │ UInt64 │
   └─────────────────────┴────────┘