{"id":13703483,"url":"https://github.com/get-select/dbt-snowflake-query-tags","last_synced_at":"2026-01-28T19:23:00.357Z","repository":{"id":65809602,"uuid":"599050565","full_name":"get-select/dbt-snowflake-query-tags","owner":"get-select","description":"From the SELECT team, a dbt package to automatically tag dbt-issued queries with informative metadata. ","archived":false,"fork":false,"pushed_at":"2026-01-19T17:02:33.000Z","size":89,"stargazers_count":53,"open_issues_count":4,"forks_count":16,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-19T23:13:23.419Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://select.dev","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/get-select.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":"supported_adapters.env","governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-02-08T10:53:49.000Z","updated_at":"2026-01-19T17:01:54.000Z","dependencies_parsed_at":"2026-01-19T19:04:05.209Z","dependency_job_id":null,"html_url":"https://github.com/get-select/dbt-snowflake-query-tags","commit_stats":null,"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"purl":"pkg:github/get-select/dbt-snowflake-query-tags","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/get-select%2Fdbt-snowflake-query-tags","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/get-select%2Fdbt-snowflake-query-tags/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/get-select%2Fdbt-snowflake-query-tags/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/get-select%2Fdbt-snowflake-query-tags/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/get-select","download_url":"https://codeload.github.com/get-select/dbt-snowflake-query-tags/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/get-select%2Fdbt-snowflake-query-tags/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28849877,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-28T15:15:36.453Z","status":"ssl_error","status_checked_at":"2026-01-28T15:15:13.020Z","response_time":57,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T21:00:55.553Z","updated_at":"2026-01-28T19:23:00.351Z","avatar_url":"https://github.com/get-select.png","language":null,"funding_links":[],"categories":["Packages"],"sub_categories":[],"readme":"# dbt-snowflake-query-tags\n\nFrom the [SELECT](https://select.dev) team, a dbt package to automatically tag dbt-issued queries with informative metadata. This package uses both query comments and query tagging.\n\nAn example query comment contains:\n\n```json\n{\n    \"dbt_snowflake_query_tags_version\": \"2.3.2\",\n    \"app\": \"dbt\",\n    \"dbt_version\": \"1.4.0\",\n    \"project_name\": \"my_project\",\n    \"target_name\": \"dev\",\n    \"target_database\": \"dev\",\n    \"target_schema\": \"dev\",\n    \"invocation_id\": \"4ffa20a1-5d90-4a27-a58a-553bb6890f25\",\n    \"node_refs\": [\n        \"model_b\",\n        \"model_c\"\n    ],\n    \"node_name\": \"model_a\",\n    \"node_alias\": \"model_a\",\n    \"node_package_name\": \"my_project\",\n    \"node_original_file_path\": \"models/model_a.sql\",\n    \"node_database\": \"dev\",\n    \"node_schema\": \"dev\",\n    \"node_id\": \"model.my_project.model_a\",\n    \"node_resource_type\": \"model\",\n    \"node_tags\": [\"tag_1\", \"tag_2\"],\n    \"node_meta\": {\"owner\": \"@alice\", \"model_maturity\": \"in dev\"},\n    \"materialized\": \"incremental\",\n    \"full_refresh\": false,\n    \"which\": \"run\"\n\n    -- dbt Cloud only\n    \"dbt_cloud_project_id\": \"146126\",\n    \"dbt_cloud_job_id\": \"184124\",\n    \"dbt_cloud_run_id\": \"107122910\",\n    \"dbt_cloud_run_reason_category\": \"other\",\n    \"dbt_cloud_run_reason\": \"Kicked off from UI by niall@select.dev\",\n}\n```\n\nQuery tags are used solely for attaching the `is_incremental` flag, as this isn't available to the query comment:\n\n```json\n{\n    \"dbt_snowflake_query_tags_version\": \"2.3.2\",\n    \"app\": \"dbt\",\n    \"is_incremental\": true\n}\n```\n\n## Quickstart\n\n1. Add this package to your `packages.yml` file, then install it with `dbt deps`.\n\n```yaml\npackages:\n  - package: get-select/dbt_snowflake_query_tags\n    version: [\"\u003e=2.0.0\", \"\u003c3.0.0\"]\n```\n\n2. Adding the query tags\n\nOption 1: If running dbt \u003c 1.2, create a folder named `macros` in your dbt project's top level directory (if it doesn't exist). Inside, make a new file called `query_tags.sql` with the following content:\n\n```sql\n{% macro set_query_tag() -%}\n{% do return(dbt_snowflake_query_tags.set_query_tag()) %}\n{% endmacro %}\n\n{% macro unset_query_tag(original_query_tag) -%}\n{% do return(dbt_snowflake_query_tags.unset_query_tag(original_query_tag)) %}\n{% endmacro %}\n```\n\nOption 2: If running dbt \u003e= 1.2, simply configure the dispatch search order in `dbt_project.yml`.\n\n```yaml\ndispatch:\n  - macro_namespace: dbt\n    search_order:\n      - \u003cYOUR_PROJECT_NAME\u003e\n      - dbt_snowflake_query_tags\n      - dbt\n```\n\n3. To configure the query comments, add the following config to `dbt_project.yml`.\n\n```yaml\nquery-comment:\n  comment: '{{ dbt_snowflake_query_tags.get_query_comment(node) }}'\n  append: true # Snowflake removes prefixed comments.\n```\n\nThat's it! All dbt-issued queries will now be tagged.\n\n## Adding additional metadata\n\n### Query comments\n\n#### Meta and tag model configs\n\nBoth [meta](https://docs.getdbt.com/reference/resource-configs/meta) and [tag](https://docs.getdbt.com/reference/resource-configs/tags) configs are automatically added to the query comments.\n\n#### 'extra' kwarg\n\nTo add arbitrary keys and values to the comments, you can use the `extra` kwarg when calling `dbt_snowflake_query_tags.get_query_comment`. For example, to add a `run_started_at` key and value to the comment, we can do:\n\n```yaml\nquery-comment:\n  comment: '{{ dbt_snowflake_query_tags.get_query_comment(node, extra={\"run_started_at\": builtins.run_started_at | string }) }}'\n  append: true # Snowflake removes prefixed comments.\n```\n\n#### Adding env vars to query comments\n\nHere's an example of how you can add environment variables into the query comment:\n\n```sql\nquery-comment:\n  comment: \u003e\n    {{ dbt_snowflake_query_tags.get_query_comment(\n      node,\n      extra={\n        'CI_PIPELINE_ID': env_var('CI_PIPELINE_ID'),\n        'CI_JOB_NAME': env_var('CI_JOB_NAME'),\n        'CI_COMMIT_REF_NAME': env_var('CI_COMMIT_REF_NAME'),\n        'CI_RUNNER_TAGS': env_var('CI_RUNNER_TAGS')\n      }\n    ) }}\n  append: true # Snowflake removes prefixed comments.\n```\n\n### Query tags\n\nTo extend the information added in the query tags, there are a few options:\n\n#### Model config\n\nSet the [query_tag](https://docs.getdbt.com/reference/resource-configs/snowflake-configs#query-tags) config value to a mapping type. Example:\n\nModel (works for dbt Core)\n```sql\n{{ config(\n    query_tag = {'team': 'data'}\n) }}\n\nselect ...\n```\n\nor (works for dbt Core and Fusion)\n```sql\n{{ config(\n    query_tag = \"{'team': 'data'}\"\n) }}\n\nselect ...\n```\n\nResults in the following query tag. The additional information is added by this package.\n```\n'{\"team\": \"data\", \"app\": \"dbt\", \"dbt_snowflake_query_tags_version\": \"2.3.2\", \"is_incremental\": true}'\n```\n\nNote that using a non-mapping type in the `query_tag` config will result in a warning, and the config being ignored.\n\nModel\n```sql\n{{ config(\n    query_tag = 'data team'\n) }}\n\nselect ...\n```\n\nWarning:\n```\ndbt-snowflake-query-tags warning: the query_tag config value of 'data team' is not a mapping type, so is being ignored. If you'd like to add additional query tag information, use a mapping type instead, or remove it to avoid this message.\n```\n\n#### Profiles.yml\n\nAdditionally, you can set the `query_tag` value in the `profiles.yml`. This must be a valid mapping, not a string.\n\nprofiles.yml\n```yml\ndefault:\n  outputs:\n    dev:\n      +query_tag:\n        team: data\n      ...\n  target: dev\n```\n\n#### Environment variables\n\nAnother option is to use the optional project variable `env_vars_to_query_tag_list` to provide a list of environment variables to pull query tag values from.\n\nExample:\n\ndbt_project.yml:\n```yml\n  vars:\n    env_vars_to_query_tag_list: ['TEAM','JOB_NAME']\n```\n\nResults in a final query tag of\n```\n'{\"team\": \"data\", \"job_name\": \"daily\", \"app\": \"dbt\", \"dbt_snowflake_query_tags_version\": \"2.3.2\", \"is_incremental\": true}'\n```\n\n#### 'extra' kwarg\n\nLike the query comment macro, the query tag macro also supports an 'extra' kwarg. To make use of it, you'll need to configure this package following the dbt \u003c 1.2 instructions. Then you can add any logic you like for additional query tag metadata in `query_tags.sql`.\n\n```\n{% macro set_query_tag() -%}\n    {% do return(dbt_snowflake_query_tags.set_query_tag(\n        extra={\n            'custom_config_property': config.get('custom_config_property'),\n        }\n    )) %}\n{% endmacro %}\n\n{% macro unset_query_tag(original_query_tag) -%}\n    {% do return(dbt_snowflake_query_tags.unset_query_tag(original_query_tag)) %}\n{% endmacro %}\n```\n\n## Contributing\n\n### Adding a CHANGELOG Entry\nWe use changie to generate CHANGELOG entries. Note: Do not edit the CHANGELOG.md directly. Your modifications will be lost.\n\nFollow the steps to [install changie](https://changie.dev/guide/installation/) for your system.\n\nOnce changie is installed and your PR is created, simply run these changie commands:\n1. `changie new`: changie will walk you through the process of creating a changelog entry.\n2. `changeie batch x.x.x` where x.x.x is the new version needed.  You can chech the `.changes` folder to know the next version number.\n3. `changie merge`\n\nNext, update `dbt_project.yaml` with the new version number.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fget-select%2Fdbt-snowflake-query-tags","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fget-select%2Fdbt-snowflake-query-tags","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fget-select%2Fdbt-snowflake-query-tags/lists"}