그래프 연산자
그래프 연산자 (Graph operators)
+(플러스), n+(엔 플러스), @(앳) 연산자를 사용해 선택 범위를 리소스의 상위(ancestor)나 하위(descendant)로 확장하는 방법을 다뤄요.
출처: 문서
본문
"plus" 연산자 (The "plus" operator)
+ 연산자는 리소스의 조상(업스트림 의존성) 또는 후손(다운스트림 의존성)을 포함하도록 선택을 확장해요. 이 연산자는 개별 모델, 태그, 그 외 리소스에 대해 동작해요.
- 모델/리소스 뒤에 배치 — 리소스 자신과 모든 후손(다운스트림 의존성)을 포함해요.
- 모델/리소스 앞에 배치 — 리소스 자신과 모든 조상(업스트림 의존성)을 포함해요.
- 모델/리소스 양쪽에 배치 — 리소스 자신, 모든 조상, 모든 후손을 포함해요.
dbt run --select "my_model+" # select my_model and all descendants
dbt run --select "+my_model" # select my_model and all ancestors
dbt run --select "+my_model+" # select my_model, and all of its ancestors and descendants
명령에서 더 구체적인 범위를 위해 셀렉터와 함께 사용할 수 있어요. --exclude 플래그와 결합하면 포함되는 내용을 더 세밀하게 제어할 수도 있어요.
"n-plus" 연산자 (The "n-plus" operator)
+ 연산자의 동작을 거쳐갈 엣지 수로 정량화해 조정할 수 있어요.
dbt run --select "my_model+1" # select my_model and its first-degree descendants
dbt run --select "2+my_model" # select my_model, its first-degree ancestors ("parents"), and its second-degree ancestors ("grandparents")
dbt run --select "3+my_model+4" # select my_model, its ancestors up to the 3rd degree, and its descendants down to the 4th degree
"at" 연산자 (The "at" operator)
@ 연산자는 +와 비슷하지만, 선택한 모델의 모든 후손의 모든 조상도 포함해요. 이는 선택한 모델과 그 후손을 모두 빌드하고 싶지만 그 후손들의 조상이 아직 스키마에 존재하지 않을 수 있는 지속적 통합(CI) 환경에서 유용해요. @ 연산자(모델 이름 앞에만 배치 가능)는 지정된 모델의 후손을 모두 성공적으로 빌드하는 데 필요한 만큼의 조상("parents", "grandparents" 등) 차수를 선택해요.
@snowplow_web_page_context 셀렉터는 아래 다이어그램의 세 모델을 모두 빌드해요.
dbt run --select "@my_model" # select my_model, its descendants, and the ancestors of its descendants
더 알아보기 (Learn more)
- Node selection syntax — 선택 문법 개요
- Node selector methods — 셀렉터 메서드