Skip to content

Instantly share code, notes, and snippets.

@sgoley
Created August 19, 2020 01:50
Show Gist options
  • Save sgoley/0498b1d555882b557eb9f2ca6139c552 to your computer and use it in GitHub Desktop.
Save sgoley/0498b1d555882b557eb9f2ca6139c552 to your computer and use it in GitHub Desktop.
dbt macro to grant select usage and select for all tables of a schema
{% macro grant_select_on_schemas(schemas, user) %}
{% for schema in schemas %}
grant usage on schema {{ schema }} to "{{ user }}";
grant select on all tables in schema {{ schema }} to "{{ user }}";
alter default privileges in schema {{ schema }}
grant select on tables to "{{ user }}";
{% endfor %}
{% endmacro %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment