Skip to content

feat(dbt_project): support DBT PROJECT grants#25

Open
usbrandon wants to merge 1 commit into
datacoves:mainfrom
usbrandon:feat/dbt-project-grants-upstream
Open

feat(dbt_project): support DBT PROJECT grants#25
usbrandon wants to merge 1 commit into
datacoves:mainfrom
usbrandon:feat/dbt-project-grants-upstream

Conversation

@usbrandon

Copy link
Copy Markdown
Contributor

What

Adds DBT PROJECT (dbt Projects on Snowflake) as a schema-scoped grantable resource type:

grants:
  - priv: USAGE
    on: dbt project <db>.<schema>.<proj>
    to: <runner_role>
  - priv: MONITOR
    on: dbt project <db>.<schema>.<proj>
    to: <observer_role>

USAGE executes the project (EXECUTE DBT PROJECT) and lists/retrieves its files; MONITOR exposes project details + run history in Snowsight. Schema-scope CREATE DBT PROJECT supports deploy-from-Workspace.

Change (mirrors the CORTEX SEARCH SERVICE grant support)

  • enums.py: ResourceType.DBT_PROJECT.
  • privs.py: DbtProjectPriv (ALL/MONITOR/OWNERSHIP/USAGE), PRIVS_FOR_RESOURCE_TYPE entry, SchemaPriv.CREATE_DBT_PROJECT.
  • resources/resource.py: RESOURCE_SCOPES SchemaScope() (grants only; no concrete resource class yet).
  • data_provider.py: fetch_dbt_project() — needed to resolve on: dbt project grant references at plan time (SHOW DBT PROJECTS).
  • Tests: TestDbtProjectPriv + test_grant_on_dbt_project.
  • Docs: docs/resources/dbt_project.md, grant.md example, mkdocs.yml nav.

Validation

Verified end-to-end against a live account: created a dbt project object, and GRANT USAGE/MONITOR ON DBT PROJECT ... TO ROLE plans + applies cleanly. Full dbt project resource modeling (CREATE DBT PROJECT ... FROM) is left for a future PR — this covers grants.

🤖 Generated with Claude Code

Adds DBT PROJECT (dbt Projects on Snowflake) as a schema-scoped grantable
resource type so users can write:

    grants:
      - priv: USAGE
        on: dbt project <db>.<schema>.<proj>
        to: <runner_role>
      - priv: MONITOR
        on: dbt project <db>.<schema>.<proj>
        to: <observer_role>

USAGE is required to EXECUTE DBT PROJECT and list/retrieve project files;
MONITOR exposes project details + run history in Snowsight. The schema-scope
priv CREATE DBT PROJECT is added to SchemaPriv for deploy-from-Workspace flows.

Changes (mirrors the CORTEX SEARCH SERVICE grant PR):
- ResourceType.DBT_PROJECT added to the enum (alphabetical).
- DbtProjectPriv(Priv) with ALL/MONITOR/OWNERSHIP/USAGE.
- PRIVS_FOR_RESOURCE_TYPE entry mapping the type to the priv class.
- SchemaPriv.CREATE_DBT_PROJECT added.
- RESOURCE_SCOPES entry registering SchemaScope() (INTEGRATION/Cortex
  precedent: no concrete resource class yet, just enough to let
  `priv: ... on: dbt project ...` parse and render).
- Unit tests: DbtProjectPriv enum values + end-to-end Grant SQL for USAGE
  and MONITOR.
- Docs: docs/resources/dbt_project.md (new), grant.md example, mkdocs nav.

Full dbt project resource modeling (CREATE DBT PROJECT ... FROM <workspace>
with profiles/target config) is left for a future PR — this covers grants.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016L3b4GTh5nyFy5vxQ6e9TY
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant