Starrocks configurations

Starrocks configurations

StarRocks 어댑터에서 dbt 모델을 어떻게 구성하는지 다루는 페이지예요. materialization 유형, 키, 테이블 타입, 분산·파티셔닝, 프로퍼티 등을 모델 config로 지정할 수 있어요.

출처: 문서

본문

Model Configuration

dbt 모델은 다음 문법으로 구성할 수 있어요.

dbt_project.yml

models:
  <resource-path>:
    materialized: table       // table or view or materialized_view
    keys: ['id', 'name', 'some_date']
    table_type: 'PRIMARY'     // PRIMARY or DUPLICATE or UNIQUE
    distributed_by: ['id']
    buckets: 3                // default 10
    partition_by: ['some_date']
    partition_by_init: ["PARTITION p1 VALUES [('1971-01-01 00:00:00'), ('1991-01-01 00:00:00')),PARTITION p1972 VALUES [('1991-01-01 00:00:00'), ('1999-01-01 00:00:00'))"]
    properties: [{"replication_num":"1", "in_memory": "true"}]
    refresh_method: 'async' // only for materialized view default manual

models/properties.yml

models:
  - name: <model-name>
    config:
      materialized: table       // table or view or materialized_view
      keys: ['id', 'name', 'some_date']
      table_type: 'PRIMARY'     // PRIMARY or DUPLICATE or UNIQUE
      distributed_by: ['id']
      buckets: 3                // default 10
      partition_by: ['some_date']
      partition_by_init: ["PARTITION p1 VALUES [('1971-01-01 00:00:00'), ('1991-01-01 00:00:00')),PARTITION p1972 VALUES [('1991-01-01 00:00:00'), ('1999-01-01 00:00:00'))"]
      properties: [{"replication_num":"1", "in_memory": "true"}]
      refresh_method: 'async' // only for materialized view default manual

models/.sql

{{ config(
    materialized = 'table',
    keys=['id', 'name', 'some_date'],
    table_type='PRIMARY',
    distributed_by=['id'],
    buckets=3,
    partition_by=['some_date'],
    ....
) }}

Configuration Description

각 config 항목의 상세 설명은 원문의 Configuration Description 표를 참고하세요. materialized(테이블/뷰/materialized_view), keys(프라이머리·듀플리케이트·유니크 키), table_type, distributed_by, buckets(기본 10), partition_by, partition_by_init, properties, refresh_method 등이 해당돼요.

Read From Catalog

먼저 이 카탈로그를 StarRocks에 추가해야 해요. 다음은 hive의 예시예요.

CREATE EXTERNAL CATALOG `hive_catalog`
PROPERTIES (
    "hive.metastore.uris"  =  "thrift://127.0.0.1:8087",
    "type"="hive"
);

다른 유형의 카탈로그 추가 방법은 카탈로그 개요 문서에서 찾을 수 있어요. 그다음 sources.yaml 파일을 작성해요.

sources:
  - name: external_example
    schema: hive_catalog.hive_db
    tables:
      - name: hive_table_name

마지막으로 아래 마크로 인용을 사용할 수 있어요.

{{ source('external_example', 'hive_table_name') }}

더 알아보기 (Learn more)