# dbt Core

{% hint style="info" %}
**Required role to configure:** [Admin](/external-docs/fundamentals/settings/user-roles.md) or higher.

Users with lower roles can view this feature but cannot change its configuration.
{% endhint %}

Seemore supports dbt core by using custom tags for classifying data assets that run through DBT core.

1. In order to integrate you would need to add the following tags package - [dbt snowflake query tags package](https://github.com/get-select/dbt-snowflake-query-tags?tab=readme-ov-file#quickstart).
2. In order to add more informative metadata such as data orchestration tools that execute the DBT Queries[ add the following code](#airflow-example).

#### Quickstart

1. Add this package to your `packages.yml` file, then install it with `dbt deps`.

```yaml
packages:
  - package: get-select/dbt_snowflake_query_tags
    version: [">=2.0.0", "<3.0.0"]
```

2. Adding the query tags

Option 1: If running dbt >= 1.2, simply configure the dispatch search order in `dbt_project.yml`.

```yaml
dispatch:
  - macro_namespace: dbt
    search_order:
      - <YOUR_PROJECT_NAME>
      - dbt_snowflake_query_tags
      - dbt
```

Option 2: If running dbt < 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:

```sql
{% macro set_query_tag() -%}
{% do return(dbt_snowflake_query_tags.set_query_tag()) %}
{% endmacro %}

{% macro unset_query_tag(original_query_tag) -%}
{% do return(dbt_snowflake_query_tags.unset_query_tag(original_query_tag)) %}
{% endmacro %}
```

3. To configure the query comments, add the following config to `dbt_project.yml`.

```yaml
query-comment:
  comment: '{{ dbt_snowflake_query_tags.get_query_comment(node) }}'
  append: true # Snowflake removes prefixed comments.
```

That's it! All dbt-issued queries will now be tagged.

\
Once the dbt package to automatically tag dbt-issued queries with informative metadata has been added you can add more informative information such as **Orchestration tools** used to execute DBT queries.

#### Airflow Example

```yaml
query-comment:
  comment: >
    {{ dbt_snowflake_query_tags.get_query_comment(
      node,
      extra={
        'workflow_id': env_var('AIRFLOW_CTX_DAG_ID', 'default_dag_id'),
        'job_id': env_var('AIRFLOW_CTX_TASK_ID', 'default_task_id'),
        'scheduler': 'airflow'
      }
    ) }}
  append: true # Snowflake removes prefixed comments.
```

**Github Actions**

```yaml
query-comment:
  comment: >
    {{ dbt_snowflake_query_tags.get_query_comment(
      node,
      extra={
        'workflow_id': env_var('GITHUB_WORKFLOW', 'default_dag_id'),
        'job_id': env_var('GITHUB_JOB', 'default_task_id'),
        'scheduler': 'github_actions'
      }
    ) }}
  append: true # Snowflake removes prefixed comments.
```

**Gitlab**

```yaml
query-comment:
  comment: >
    {{ dbt_snowflake_query_tags.get_query_comment(
      node,
      extra={
        'workflow_id': env_var('CI_PIPELINE_ID', 'default_dag_id'),
        'job_id': env_var('CI_JOB_NAME', 'default_task_id'),
        'scheduler': 'gitlab'
      }
    ) }}
  append: true # Snowflake removes prefixed comments.
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.seemoredata.io/external-docs/fundamentals/getting-set-up/setting-integrations/dbt/dbt-core.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
