check_cols

check_cols

strategy: check 스냅샷에서 변경 여부를 비교할 컬럼의 목록을 지정하는 설정이에요. 특정 컬럼만 골라서 감시하거나, all 값으로 전부 비교할 수도 있어요. 스냅샷 쿼리 결과에서 비교 대상이 되는 컬럼을 정리해서 기록해두는 용도죠.

출처: 문서

본문

check_cols는 스냅샷 쿼리 결과 안의 컬럼 중 변경 여부를 확인할 컬럼들의 목록이에요. 대신 all 값을 쓰면 모든 컬럼을 비교하도록 지정할 수도 있는데, 이 경우 성능이 떨어질 수 있어요. check 전략을 사용한다면 이 파라미터는 반드시 필요해요.

snapshots:
- name: snapshot_name
  relation: source('my_source', 'my_table')
  config:
    schema: string
    unique_key: column_name_or_expression
    strategy: check
    check_cols:
      - column_name
snapshots:
  <resource-path>:
    +strategy: check
    +check_cols: [column_name] | all

기본값 (Default)

기본값은 제공되지 않아요.

예시 (Examples)

변경 여부를 확인할 컬럼 목록 지정하기

snapshots:
  - name: orders_snapshot_check
    relation: source('jaffle_shop', 'orders')
    config:
      schema: snapshots
      unique_key: id
      strategy: check
      check_cols:
        - status
        - is_cancelled

이 스냅샷을 하위 모델에서 조회하려면 이렇게 해요: select * from {{ ref('orders_snapshot_check') }}

모든 컬럼의 변경 여부 확인하기

snapshots:
  - name: orders_snapshot_check
    relation: source('jaffle_shop', 'orders')
    config:
      schema: snapshots
      unique_key: id
      strategy: check
      check_cols: all

더 알아보기 (Learn more)