dbt-snow-mask icon indicating copy to clipboard operation
dbt-snow-mask copied to clipboard

Ability to pass in node and custom_schema_name

Open aaverbec opened this issue 11 months ago • 2 comments

We use a custom generate_schema_name macro for our models. I have been unable to figure out how to duplicate this logic for where it should attempt to place the masking policy. When our ADO pipelines for new PRs are running, it doesn't seem to be able to determine the correct schema to place it in. I can either hard code it using the common schema name variable. Or I can leave it to place it in every schema that a model uses.

In this case, the use common masking policy schema is technically variable. When local dev / PRs (which we use a target.name to determine if it's a PR) then use the default schema. When it's our dev/sandbox/prod dbt environments, use a common schema.

The purpose for this is that we want to use a common schema (I don't need 30 copies of a masking policy in each schema where a model uses them that are all identical), but we don't want people's development creating objects in the "real" schemas either.

aaverbec avatar Mar 12 '24 19:03 aaverbec

I was able to enable this by invoking the custom macro in the variable definition in dbt_project.yml:

common_masking_policy_schema: '{{ generate_schema_name("GOVERNANCE") }}'

mjahammel avatar Mar 22 '24 14:03 mjahammel

@mjahammel I don't believe that would work for our case since our macro has a couple inputs and when I tried to call it, it would tell me that the variables weren't populated.

Beginning of the macro definition {% macro generate_schema_name(custom_schema_name, node) -%}

aaverbec avatar Mar 22 '24 15:03 aaverbec