limit

limit (실패 한도)

테스트 쿼리가 반환할 실패(failure) 개수를 제한하는 설정이에요. 대용량 데이터셋을 다루거나 데이터베이스에 실패를 저장할 때 이 설정을 쓰는 걸 권장해요.

출처: dbt 공식 문서

본문

특정 테스트

generic(schema) 테스트의 특정 인스턴스를 설정해요.

models/.yml


models:
  - name: large_table
    columns:
      - name: very_unreliable_column
        data_tests:
          - accepted_values:
              arguments: # available in v1.10.5 and higher. Older versions can set the <argument_name> as the top-level property.
                values: ["a", "b", "c"]
              config:
                limit: 1000  # will only include the first 1000 failures

일회용 테스트

one-off(data) 테스트를 설정해요.

tests/.sql

{{ config(limit = 1000) }}

select ...

Generic 테스트 블록

generic(schema) 테스트의 모든 인스턴스 기본값을 설정하려면, 그 테스트 블록(정의) 안에서 설정을 넣어요.

macros/.sql

{% test <testname>(model, column_name) %}

{{ config(limit = 500) }}

select ...

{% endtest %}

프로젝트 수준

패키지나 프로젝트의 모든 테스트 기본값을 설정해요.

dbt_project.yml

data_tests:
  +limit: 1000  # all tests

  <package_name>:
    +limit: 50 # tests in <package_name>

더 알아보기 (Learn more)