Notice
Recent Posts
Recent Comments
Link
250x250
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- bar cahrt
- mysql
- spring boot
- 크롤링
- ksql
- 쿠버네티스
- kafka
- airflow
- query history
- UI for kafka
- spark
- 도커
- Materializations
- numpartitions
- 카프카
- 윈도우
- 파이썬
- dbt_project
- CDC
- docker
- k9s
- 모바일
- DBT
- Java
- KubernetesPodOperator
- polars
- proerty
- Python
- freshness
- 동적 차트
Archives
- Today
- Total
데이터 엔지니어 이것저것
dbt codegen 본문
728x90
dbt 코드를 생성하는 매크로
관련 패키지 추가
packages:
- package: dbt-labs/dbt_utils
version: 1.1.1
- package: dbt-labs/codegen
version: 0.11.0
source.yml 생성하기
dbt run-operation generate_source --args 'schema_name: public'
하고 이런식으로 명령어를 입력하면 해당 스키마에 존재한 테이블들을 source.yml 파일 형태로 출력해준다
다른 추가 옵션을 설정하면 데이터 타입등도 추가가 가능하다
dbt run-operation generate_source --args '{"schema_name": "public", "generate_columns" : ture, "include_descriptions" : true}'
model 생성하기
dbt run-operation generate_base_model --args '{"source_name": "public", "table_name": "actor", "materialized": "view"}'
schema.yml 생성하기
실행하기 전 dbt run을 통해 생성해둔 모델들을 실행시켜야한다.
dbt run-operation generate_model_yaml --args '{"model_names": ["actor", "actor_info"]}'
이런식으로 생성이 가능하다.
docs.md
{% docs actor_id %}
test
{% enddocs %}
docs.md에 이런식으로 생성하고, 참조하면 된다.
models:
- name: actor
description: ""
columns:
- name: actor_id
data_type: integer
description: '{{ doc("actor_id") }}'
https://github.com/dbt-labs/dbt-codegen
GitHub - dbt-labs/dbt-codegen: Macros that generate dbt code
Macros that generate dbt code. Contribute to dbt-labs/dbt-codegen development by creating an account on GitHub.
github.com
728x90
'오픈소스 > dbt' 카테고리의 다른 글
ref () vs source() (1) | 2024.01.07 |
---|---|
dbt elementary (0) | 2023.12.14 |
dbt docs (0) | 2023.11.19 |
dbt packages (0) | 2023.11.19 |
dbt Materializations (0) | 2023.11.17 |