dbt-labs / dbt-snowflake

dbt-snowflake contains all of the code enabling dbt to work with Snowflake
https://getdbt.com
Apache License 2.0
292 stars 175 forks source link

[ADAP-1024] [Feature] Save tags to Snowflake using object tagging feature #827

Open kanomaxb opened 1 year ago

kanomaxb commented 1 year ago

Is this your first time submitting a feature request?

Describe the feature

Besides dbt tags there should be possibility to define 'snowflake-tags' for tables and columns (and possibly schemas), which would be persisted to Snowflake as tags (https://docs.snowflake.com/en/user-guide/object-tagging).

Describe alternatives you've considered

We are aware of the dbt-snowflake-utils package by Montreal Analytics, which now has a macro that creates Snowflake tags from model/column meta.

It is not usable for tag-based masking though, because there is a time gap between materializing a table and creating a tag (currently it creates tags in on-run-end, so when all models are ready), which would create a serious vulnerability in PII protection. Therefore tags need to be a part of the CTAS (same as masking policies problem described in dbt-labs/dbt-adapters#85

Who will this benefit?

Tags are useful for monitoring, but also they enable a powerful feature called tag-based masking, which is getting more and more popular.

Are you interested in contributing this feature?

No response

Anything else?

This feature has already been requested (#104), but closed with suggestion, that the dbt-snowflake-utils macro is a sufficient alternative. It may be for some cases, but we take our PII protection too seriously to enable a time gap between table materialization and tag creation.

michael-the1 commented 9 months ago

This is also important for us, for exactly the same reasons as yours. We currently solve this using a custom materialization, but that comes with its own downsides of course.

Implementation is pretty straightforward. For the definition, I like the names dbt-snowflake-utils, though I'd put them at the top level:

# schema.yml

models:
  - name: ACCOUNT
    +schema: FINANCE
    database_tags:
      accounting_row_string: a

    columns:
      - name: ACCOUNT_NAME
        database_tags:
          accounting_col_string: b