Free tool · BigQuery and Snowflake
Query attribution checker
Cost by dbt model or dashboard only works when queries carry a mark the tools left. Paste one query's metadata and see what dwhat's audit would recognise: the tool, the dbt model and the dashboard — or why it would show the query as unattributed.
SQL comments can carry sensitive values — names, ids, emails, literals in the query. Paste only what you are allowed to, and trim the rest: the marks are all this needs.
Check your metadata
What the audit would recognise
What dwhat reads, and where to find it
Some marks are what a tool writes by default; the others are dwhat's own convention, which you add. Either way a mark only changes queries run after it is added: the history already in your warehouse keeps the metadata it had, and nothing can attribute those queries after the fact.
SQL comments
- dbt adds a comment to every query it runs by default: /* {"app": "dbt", …, "node_id": "model.my_project.orders"} */. dwhat reads the model from node_id. dbt's documentation says it goes at the end of the query on Snowflake, so that it is not stripped, and at the beginning elsewhere.
- Looker adds a "-- Looker Query Context '{…}'" comment; dwhat names the dashboard from its dashboard_id when it has one.
- Metabase starts its SQL with "-- Metabase:: userID: … queryType: … queryHash: …". That names the tool, not the dashboard.
- dwhat reads no comment of its own: a dashboard named in a free-form comment is not read. Use a job label or a query tag for that.
dbt's default comment, as dwhat reads it
/* {"app": "dbt", "node_id": "model.my_project.orders"} */BigQuery: recent query text that carries a dbt comment
SELECT job_id, creation_time, query FROM `region-us`.INFORMATION_SCHEMA.JOBS_BY_PROJECT WHERE creation_time >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 1 DAY) AND job_type = 'QUERY' AND REGEXP_CONTAINS(query, r'"app": *"dbt"') ORDER BY creation_time DESC LIMIT 20
Documentation: dbt: query-comment · BigQuery: INFORMATION_SCHEMA.JOBS view · Snowflake: QUERY_HISTORY view
BigQuery job labels
- With query-comment: {job-label: true} in dbt_project.yml, dbt-bigquery sends the comment's fields as job labels too. Label values hold only lowercase letters, digits, underscores and dashes, so node_id arrives as model_my_project_orders: the dots are gone.
- Google documents that every query Looker Studio sends to BigQuery carries the label requestor:looker_studio. dwhat also reads looker_studio_report_id when a job has it.
- dwhat's convention, not a vendor default: a dashboard label (and, if you like, a tool label) on the job. It is read last, so it replaces a dashboard or tool any other mark gives.
A dashboard label, set for every query in a BigQuery session
SET @@query_label = "dashboard:revenue_daily";
BigQuery: recent jobs and their labels, as JSON to paste here
SELECT job_id, creation_time, TO_JSON_STRING(labels) AS labels FROM `region-us`.INFORMATION_SCHEMA.JOBS_BY_PROJECT WHERE creation_time >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 1 DAY) AND job_type = 'QUERY' AND ARRAY_LENGTH(labels) > 0 ORDER BY creation_time DESC LIMIT 20
Documentation: BigQuery: add labels to jobs · BigQuery: labels, and their requirements · dbt: query-comment · Looker Studio: monitor and analyze BigQuery data source queries · BigQuery: INFORMATION_SCHEMA.JOBS view
Snowflake QUERY_TAG
- QUERY_TAG is a Snowflake session parameter of up to 2,000 characters. Snowflake sets none by default, and shows it in the query_tag column of QUERY_HISTORY.
- dwhat's convention, not a vendor default: a tag that is JSON with a dashboard key (and tool, dbt_model or model if you like), or key:value pairs separated by ; or , such as dashboard:Revenue daily. A tag is read last, so it replaces a dashboard or tool any comment gives.
A dashboard tag, set for a session
ALTER SESSION SET QUERY_TAG = '{"dashboard": "Revenue daily", "tool": "Hex"}';Snowflake: recent queries with a tag
SELECT query_id, start_time, query_tag
FROM snowflake.account_usage.query_history
WHERE start_time >= DATEADD('day', -1, CURRENT_TIMESTAMP())
AND COALESCE(query_tag, '') <> ''
ORDER BY start_time DESC
LIMIT 20Documentation: Snowflake: the QUERY_TAG parameter · Snowflake: QUERY_HISTORY view
What it does not do
- It does not guess. A table name, a schema or a free-form comment is not a mark, and a query with no mark is unattributed — in this checker and in the audit.
- It checks one query's metadata. It does not read your warehouse, price anything or change your dbt or BI configuration.
- A label or tag that is valid but uses keys dwhat does not read stays unattributed: the audit cannot know which of your keys means "dashboard".
See what those models and dashboards cost
The audit reads 45 days of query history with a read-only account and splits the cost by user, dbt model and dashboard, with the unattributed share shown as such.
The link is the checker's address alone — never what you pasted.
Related guides
- Cost per dbt model on BigQuery and SnowflakeSQL that attributes BigQuery and Snowflake compute cost to dbt models, using the node_id in dbt's default query comment and dbt-bigquery's job labels.
- Find your most expensive BigQuery queries with SQLCopy-paste SQL that lists the BigQuery queries that cost the most over the last 30 days, from INFORMATION_SCHEMA.JOBS_BY_PROJECT, with bytes billed, slot hours and estimated cost.
- Snowflake cost per user and per query, with SQLCopy-paste SQL for Snowflake credits by user and by query from QUERY_ATTRIBUTION_HISTORY, and idle warehouse time from WAREHOUSE_METERING_HISTORY.