I want to do different things depending if my sql file was in staging subdirectory or in mart subdirectory.
More specifically i want to grant different groups permissions depending on if its mart or staging
Currently i have different models that all have staging and mart directories in them, i want to modify my post-hook so it will do different things if file was from staging dict or not.
For example right now, in dbt_project.yml file i only have 1 post-hook in my models part:
models:
model_repo:
+persist_docs:
relation: true
columns: true
+post-hook:
- "INSERT INTO {{ this }} values (NOW(),'post-hook')"
Is there a way i can have custom post-hook depending if it is from mart or staging?
You can specify different post-hooks for staging and mart based in the resource-path:
OR
To achieve a more dynamic behavior based on the model path, you can create a macro as sugested by jtcohen6 in this comment:
Then use it: