시드 구성
시드 구성 (Seed configurations)
시드(seed) 구성에는 시드 전용 구성과 일반 구성이 있어요. 시드는 YAML 파일에서만 구성할 수 있고, CSV 파일 안에서는 구성할 수 없어요.
출처: 문서
본문
Available configurations
Seed-specific configurations
리소스 전용 구성은 여러 리소스 타입이 아닌 dbt 리소스 타입 하나에만 적용돼요. 이 설정은 프로젝트 파일(dbt_project.yml), 속성 파일(models/properties.yml — 모델의 경우, 다른 리소스도 마찬가지), 또는 리소스 파일 안에서 {{ config() }} 매크로로 정의할 수 있어요.
다음 리소스 전용 구성은 Seeds에만 사용할 수 있어요:
dbt_project.yml
seeds:
<resource-path>:
+quote_columns: true | false
+column_types: {column_name: datatype}
+delimiter: <string>
seeds/properties.yml
seeds:
- name: [<seed-name>]
config:
quote_columns: true | false
column_types: {column_name: datatype}
delimiter: <string>
General configurations
일반 구성은 여러 리소스 타입에 적용되는 더 폭넓은 운영 설정을 제공해요. 리소스 전용 구성과 마찬가지로 프로젝트 파일, 속성 파일, 또는 리소스 전용 파일에서 설정할 수 있어요.
dbt_project.yml (dbt v1.9 이상 적용)
seeds:
<resource-path>:
+enabled: true | false
+tags: <string> | [<string>]
+pre-hook: <sql-statement> | [<sql-statement>]
+post-hook: <sql-statement> | [<sql-statement>]
+database: <string>
+schema: <string>
+alias: <string>
+persist_docs: <dict>
+full_refresh: <boolean>
+meta: {<dictionary>}
+grants: {<dictionary>}
+event_time: my_time_field
seeds/properties.yml (dbt v1.9 이상 적용)
seeds:
- name: [<seed-name>]
config:
enabled: true | false
tags: <string> | [<string>]
pre_hook: <sql-statement> | [<sql-statement>]
post_hook: <sql-statement> | [<sql-statement>]
database: <string>
schema: <string>
alias: <string>
persist_docs: <dict>
full_refresh: <boolean>
meta: {<dictionary>}
grants: {<dictionary>}
event_time: my_time_field
Configuring seeds
시드는 dbt_project.yml 또는 개별 시드의 YAML 속성과 같이 YAML 파일에서만 구성할 수 있어요. 시드의 CSV 파일 안에서는 구성할 수 없어요.
시드 구성은 모델 구성처럼 계층적으로 적용돼요 — marketing 하위 디렉터리에 적용된 구성은 전체 jaffle_shop 프로젝트에 적용된 구성보다 우선하고, 특정 시드의 속성에 정의된 구성은 dbt_project.yml에 정의된 구성을 덮어써요.
Examples
모든 시드에 스키마 구성 적용
설치된 패키지의 시드를 포함한 모든 시드에 구성을 적용하려면 seeds 키 바로 아래에 구성을 중첩해요:
dbt_project.yml
seeds:
+schema: seed_data
프로젝트의 모든 시드에 스키마 구성 적용
프로젝트의 모든 시드에만(즉 설치된 패키지의 시드 제외) 구성을 적용하려면 프로젝트 이름을 리소스 경로의 일부로 제공해요.
jaffle_shop이라는 프로젝트의 경우:
dbt_project.yml
seeds:
jaffle_shop:
+schema: seed_data
마찬가지로 설치된 패키지의 이름을 사용해 해당 패키지의 시드를 구성할 수도 있어요.
시드 하나에만 스키마 구성 적용
시드 하나에만 구성을 적용하려면 전체 리소스 경로(프로젝트 이름과 하위 디렉터리 포함)를 제공해요.
seeds/marketing/properties.yml
seeds:
- name: utm_parameters
config:
schema: seed_data
이전 dbt 버전에서는 dbt_project.yml에 구성을 정의하고 전체 리소스 경로(프로젝트 이름과 하위 디렉터리 포함)를 포함해야 해요. jaffle_shop 프로젝트에서 seeds/marketing/utm_parameters.csv 시드 파일이 있다면 다음과 같아요:
dbt_project.yml
seeds:
jaffle_shop:
marketing:
utm_parameters:
+schema: seed_data
Example seed configuration
다음은 다음 조건을 가진 프로젝트의 유효한 시드 구성이에요:
name: jaffle_shopseeds/country_codes.csv시드 파일seeds/marketing/utm_parameters.csv시드 파일
dbt_project.yml
name: jaffle_shop
...
seeds:
jaffle_shop:
+enabled: true
+schema: seed_data
# This configures seeds/country_codes.csv
country_codes:
# Override column types
+column_types:
country_code: varchar(2)
country_name: varchar(32)
marketing:
+schema: marketing # this will take precedence
더 알아보기 (Learn more)
- Seed properties — 시드 속성 정의
- Seeds — 시드 개념