schemas 변수
schemas 변수
schemas는 on-run-end 훅에서 사용할 수 있는 변수로, 이번 실행에서 dbt가 객체를 만든 스키마들의 리스트를 나타내요.
출처: 문서
본문
custom schemas를 사용하지 않으면 schemas는 대상 스키마로 평가돼요. 예: ['dbt_alice']. custom schemas를 쓰면 이것들도 포함돼요. 예: ['dbt_alice', 'dbt_alice_marketing', 'dbt_alice_finance'].
schemas 변수는 dbt가 relation을 만드는 모든 스키마에 권한을 부여할 때 유용해요. 다음과 같이 써요(참고: 이건 Redshift 특정 구문이에요):
dbt_project.yml
...
on-run-end:
- "{% for schema in schemas%}grant usage on schema {{ schema }} to group reporter;{% endfor%}"
- "{% for schema in schemas %}grant select on all tables in schema {{ schema }} to group reporter;{% endfor%}"
- "{% for schema in schemas %}alter default privileges in schema {{ schema }} grant select on tables to group reporter;{% endfor %}"
권한을 부여하는 권장 방법에 대한 더 자세한 지침이 필요하다면, 이 discourse 글을 확인해요.
더 알아보기 (Learn more)
schemas는on-run-end훅에서만 사용할 수 있어요.- 관련 개념: on-run-end context, custom schemas.