본문으로 바로가기
본문으로 바로가기

mergeTreeProjection Table Function

MergeTree 테이블에서 특정 프로젝션의 내용을 나타냅니다. 내부 구조를 조회하는 용도로 사용할 수 있습니다.

구문

mergeTreeProjection(database, table, projection)

Arguments

ArgumentDescription
databasePROJECTION을 읽어올 데이터베이스 이름입니다.
tablePROJECTION을 읽어올 테이블 이름입니다.
projection읽어올 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 │
   └─────────────────────┴────────┘