소스 속성

소스 속성 (Source properties)

소스 속성은 models/ 디렉터리의 properties.yml 파일에서 선언할 수 있어요. 소스 속성은 dbt_project.yml 파일이나 config() 블록에서는 구성할 수 없는 "특수 속성"이에요.

출처: 문서

본문

관련 문서: Using sources, Declaring resource properties

Overview

소스 속성은 model-paths 구성으로 정의된 models/ 디렉터리의 어떤 properties.yml 파일에서든 선언할 수 있어요. 소스 속성은 dbt_project.yml 파일이나 config() 블록에서 구성할 수 없는 "특수 속성"이에요. 자세한 내용은 Configs and properties를 참고해 주세요. 파일 이름은 whatever_you_want.yml처럼 정할 수 있고, models/ 디렉터리의 하위 폴더에 자유롭게 중첩할 수 있어요. models/<filename>.yml

sources:
  - name: <string> # required
    description: <markdown_string>
    database: <database_name>
    schema: <schema_name>
    loader: <string>
    config: # requires v1.1+
      <source_config>: <config_value>
      loaded_at_field: <column_name> # moved under config in v1.10
      freshness: # moved under config in v1.10
        warn_after:
          count: <positive_integer>
          period: minute | hour | day
        error_after:
          count: <positive_integer>
          period: minute | hour | day
        filter: <where-condition>
      meta: {<dictionary>} # moved under config in v1.10
      tags: [<string>] # moved under config in v1.10
    overrides: <string> # deprecated in v1.10
    quoting:
      database: true | false
      schema: true | false
      identifier: true | false
    tables:
      - name: <string> #required
        description: <markdown_string>
        identifier: <table_name>
        data_tests:
          - <test>
          - ... # declare additional tests
        config:
          loaded_at_field: <column_name>
          meta: {<dictionary>}
          tags: [<string>]
          freshness:
            warn_after:
              count: <positive_integer>
              period: minute | hour | day
            error_after:
              count: <positive_integer>
              period: minute | hour | day
            filter: <where-condition>
        quoting:
          database: true | false
          schema: true | false
          identifier: true | false
        external: {<dictionary>}
        columns:
          - name: <column_name> # required
            description: <markdown_string>
            quote: true | false
            data_tests:
              - <test>
              - ... # declare additional tests
            config:
              meta: {<dictionary>}
              tags: [<string>]
          - name: ... # declare properties of additional columns
      - name: ... # declare properties of additional source tables
  - name: ... # declare properties of additional sources

Example

models/<filename>.yml

sources:
  - name: jaffle_shop
    database: raw
    schema: public
    loader: emr # informational only (free text)
    config:
      # changed to config in v1.10
      loaded_at_field: _loaded_at # configure for all sources
      # meta fields are rendered in auto-generated documentation
      meta: # changed to config in v1.10
        contains_pii: true
        owner: "@alice"
      # Add tags to this source
      tags: # changed to config in v1.10
        - ecom
        - pii
    quoting:
      database: false
      schema: false
      identifier: false
    tables:
      - name: orders
        identifier: Orders_
        config:
          # changed to config in v1.10
          loaded_at_field: updated_at # override source defaults
        columns:
          - name: id
            data_tests:
              - unique
          - name: price_in_usd
            data_tests:
              - not_null
      - name: customers
        quoting:
          identifier: true # override source defaults
        columns:
            data_tests:
              - unique

더 알아보기 (Learn more)