종합
종합 (Putting it together)
지금까지 배운 셀렉터 문법을 조합해 복잡한 선택을 만드는 실제 예시를 보여 드릴게요. 메서드, 그래프 연산자, 집합 연산자를 한 명령에 결합하는 방법을 다뤄요.
출처: 문서
본문
dbt run --select "my_package.*+" # select all models in my_package and their children
dbt run --select "+some_model+" # select some_model and all parents and children
dbt run --select "tag:nightly+" # select "nightly" models and all children
dbt run --select "+tag:nightly+" # select "nightly" models and all parents and children
dbt run --select "@source:snowplow" # build all models that select from snowplow sources, plus their parents
dbt test --select "config.incremental_strategy:insert_overwrite,test_name:unique" # execute all `unique` tests that select from models using the `insert_overwrite` incremental strategy
이건 복잡해질 수 있어요! snowplow 데이터를 기반으로 빌드하고 export를 공급하는 모델들의 nightly 실행을 원하는데, 가장 큰 incremental 모델(그리고 다른 모델 하나도)은 제외하려고 해요.
dbt run --select "@source:snowplow,tag:nightly models/export" --exclude "package:snowplow,config.materialized:incremental export_performance_timing"
이 명령은 다음 조건을 모두 만족하는 모델을 선택해요:
- snowplow 소스에서 선택하고 그 부모들을 포함하며 "nightly" 태그가 붙은 것
- export 모델 하위 폴더에 정의된 것
단, 다음에 해당하는 모델은 제외해요:
- snowplow 패키지에 정의되고 incremental로 materialize된 것
- 이름이
export_performance_timing인 것
더 알아보기 (Learn more)
- Node selection syntax — 선택 문법 개요
- Graph operators — 그래프 연산자
- Set operators — 합집합·교집합