Start with who can explain the spend
Maple Market’s reporting and operations teams share BI_WH. Both use it, engineering owns it and nobody agrees who consumed the extra compute. Start with showback, a report that makes usage visible to the teams. Agree on ownership before finance uses it to charge budgets internally.
For a dedicated warehouse, the total can follow the responsible team. An object tag is metadata attached to an object, such as a cost center on a warehouse. On a shared warehouse, a query tag can label statements from a workload or team. Have each job or connection set a predictable QUERY_TAG, such as FINANCE or OPERATIONS, then clear or restore it before a pooled session changes owners. An object tag and a query tag have different scopes.
Choose an explicit rule for shared costs
For 8 credits of warehouse compute, assume the tagged execution amounts are 3 for Finance and 1 for Operations. Another 1 credit belongs to an untagged query and 3 belong to idle compute. Put the untagged query in UNASSIGNED until its owner is known. Keep idle in SHARED_IDLE so the warehouse owner can investigate it.
Some organizations distribute idle by a published driver such as each team’s share of query execution or reserved capacity. Reconcile to the total before and after allocating the remainder. Keep the original usage, the allocation rule and an effective date so teams can reproduce the report when ownership changes.
Use separate drivers for services that queries do not explain. Map a pipe to its ingestion owner, use a documented storage accounting rule for owned bytes and report shared transfer separately. Compare credits within the same category or convert to currency using applicable rates before combining credits with volume-based charges.
Tag the workload and reconcile its cost center
Use a fresh worksheet and a sandbox warehouse. Cost center is the finance identifier for an owner. A warehouse tag records who owns that resource. A query tag records who requested work in a shared session. Set the query tag just before the workload. Reset it before handing a pooled connection back. Neither tag is a security control.
Choose a known convention such as FINANCE|ORDERS_REPORT, where the first part is the team and the second the workload. Report by warehouse, user and workload until the owner can confirm the mapping. Keep a dated mapping from teams to cost centers. A service identity may run jobs for several teams, so a username alone may not identify the owner.
Tag a query and inspect an optional warehouse tag
Run the session example as the worksheet user. SELECT 101 models a report request and returns 101. Later history shows the tag for that SELECT. The optional object-tag block needs CREATE TAG in a writable schema plus authority to apply the tag to the dedicated warehouse. Use global APPLY TAG or APPLY on the tag with ownership of the target as documented. Inspect the tag reference after assignment and reset or remove it when the pilot ends.
ALTER SESSION SET QUERY_TAG = 'FINANCE|ORDERS_REPORT';
SELECT 101 AS order_id;
ALTER SESSION UNSET QUERY_TAG;
-- Optional sandbox warehouse cost-center tagging.
CREATE TAG <LAB_DB>.<LAB_SCHEMA>.M16D_COST_CENTER ALLOWED_VALUES 'CC100','CC200';
ALTER WAREHOUSE <SANDBOX_WH>
SET TAG <LAB_DB>.<LAB_SCHEMA>.M16D_COST_CENTER = 'CC100';
SELECT SYSTEM$GET_TAG('<LAB_DB>.<LAB_SCHEMA>.M16D_COST_CENTER', '<SANDBOX_WH>', 'WAREHOUSE');
-- After the test:
ALTER WAREHOUSE <SANDBOX_WH> UNSET TAG <LAB_DB>.<LAB_SCHEMA>.M16D_COST_CENTER;
DROP TAG <LAB_DB>.<LAB_SCHEMA>.M16D_COST_CENTER;Allocate direct credits using an explicit team map
Replace the dates and standard warehouse name; add your approved team map. SPLIT_PART gets the two parts of the query tag. A LEFT JOIN keeps unknown teams in UNASSIGNED. Use the warehouse-hour meter separately for idle. On the eight-credit fixture, keep three as idle and one as unassigned. In real usage, subtract query totals from metered attributed compute to find a timing or coverage residual as a separate line. Investigate a negative residual first, especially when queries cross window boundaries.
Use amounts without rounding until reconciliation. Observe history lag before publishing a chargeback. Keep the hourly warehouse and feature meters as source totals and price storage or transfer separately.
ALTER SESSION SET TIMEZONE = 'UTC';
WITH team_map AS (
SELECT column1 AS team, column2 AS cost_center
FROM VALUES ('FINANCE','CC100'), ('OPERATIONS','CC200')
), query_labels AS (
SELECT warehouse_name, user_name,
SPLIT_PART(TRIM(query_tag), '|', 1) AS team,
NULLIF(SPLIT_PART(TRIM(query_tag), '|', 2), '') AS workload,
credits_attributed_compute
FROM SNOWFLAKE.ACCOUNT_USAGE.QUERY_ATTRIBUTION_HISTORY
WHERE warehouse_name = 'BI_WH'
AND start_time >= '2026-10-05'::DATE AND start_time < '2026-10-12'::DATE
)
SELECT q.warehouse_name, q.user_name, COALESCE(m.team, 'UNASSIGNED') AS team,
COALESCE(m.cost_center, 'UNASSIGNED') AS cost_center,
COALESCE(q.workload, 'UNKNOWN') AS workload,
SUM(q.credits_attributed_compute) AS direct_credits
FROM query_labels q LEFT JOIN team_map m ON q.team = m.team
GROUP BY 1,2,3,4,5 ORDER BY direct_credits DESC;Explain the decision in an interview
Start with the rule, then say what you would check in a real account.
Would you use an object tag or query tag for a shared warehouse?
I would use an object tag for who owns the warehouse and a query tag for which workload requested a query. I would leave missing labels visible.
How do you allocate idle or unattributed credits?
I first reconcile the meter. I keep measured idle and missing query evidence separate, then use a documented allocation rule if finance needs a full chargeback.
Why might team totals change when a tag changes?
A report using today’s object tag can relabel old usage. I would keep a dated mapping or snapshot and use the mapping that applied at the time.
Words used in this lesson
- Showback
- A report that makes shared usage visible to its owners.
- Object tag
- Metadata assigned to an object such as a warehouse.
- QUERY_TAG
- A session parameter whose value is recorded with a query.
See how it works
Choose a step to explore the idea at your own pace.
Open the interactive explanation
Allocate Snowflake costs to teams and workloads
Assign known work
Query labels assign 3 credits to Finance and 1 to Operations.
Automatic playback is off for reduced motion. Select any step or use Previous and Next. Illustrations explain behavior; they are not live measurements.
Read the complete diagram explanation
- Assign known work
Query labels assign 3 credits to Finance and 1 to Operations.
8 warehouse credits → 3 Finance → 1 Operations
- Show the remainder
Keep 1 unassigned credit and 3 shared idle credits visible. All buckets together still total 8.
1 unassigned → 3 shared idle → 8 reconciled
Try the SQL or command
Read → predict → run in your learning environment → compare. You can also learn by reading without an account.
New to SQL? Where to run it and how to read it
A query is a question written in SQL. Snowflake runs it and returns a result table. This website shows examples; it does not connect to your account.
- No account yet? Read and predict the output first. Follow the account and Snowsight lesson when you are ready.
- For SQL practice, use a learning account in Snowsight and select an authorized role and warehouse. A role determines permissions; a warehouse supplies processing power. Follow the example’s database/schema setup when it refers to stored objects.
- Read the entire example, including comments beginning with
--. Run the selected statement or labeled block in the stated order. Examples labeled Python, shell or HTTP belong in that client, not in a SQL editor. - Compare values and row counts with the explained result. If an example deliberately causes an error, follow its rollback and cleanup steps before continuing.
- SELECT / FROM
- Choose the values to return / identify their input.
- VALUES / COLUMN1
- VALUES supplies tiny example rows. COLUMN1 means their first column, COLUMN2 their second.
- AS / WITH
- AS gives a result a readable name. WITH names a temporary query step within one statement.
- NULL / ::
- NULL means missing or unknown. The :: notation converts a value to a named data type.
- Session
- One connection and its settings. Keep related transaction steps in the same session.
- Database.schema.table
- A full address for stored data. It is separate from the warehouse that processes queries.
Need the L2_OBJECTS_LAB setup? Open the first database-object lesson →
Help with common practice errors
- No active warehouse: select a warehouse your role can use. Do not assume you need to create a new one.
- Object missing or not authorized: check the full name, required setup and active role. Ask the account owner for access if needed.
- Object already exists: setup may already have run. Read the current state or choose a fresh lab name consistently; do not add OR REPLACE blindly.
- Different result: check whether an earlier INSERT or UPDATE changed the data. VALUES examples provide their own fresh input for each statement.
Reconcile a shared warehouse allocation
WITH queries AS (
SELECT column1 AS query_tag, column2 AS credits
FROM VALUES ('FINANCE', 3.00), ('OPERATIONS', 1.00), (NULL, 1.00)
),
allocation AS (
SELECT COALESCE(NULLIF(TRIM(query_tag), ''), 'UNASSIGNED') AS cost_bucket,
SUM(credits) AS compute_credits
FROM queries
GROUP BY 1
UNION ALL
SELECT 'SHARED_IDLE', 8.00 - SUM(credits)
FROM queries
)
SELECT cost_bucket,
compute_credits,
ROUND(100 * compute_credits / NULLIF(SUM(compute_credits) OVER (), 0), 2) AS pct_of_total
FROM allocation
ORDER BY cost_bucket;What to expect and why
Each row is representative execution compute for the same fixture window. The example assumes those rows sum to the query component of the warehouse meter for that window. In a real report get idle from matched hourly warehouse metering. Keep any residual from query-window boundaries or incomplete attribution visible and reconcile it separately.
| COST_BUCKET | COMPUTE_CREDITS | PCT_OF_TOTAL |
|---|---|---|
| FINANCE | 3.00 | 37.50 |
| OPERATIONS | 1.00 | 12.50 |
| SHARED_IDLE | 3.00 | 37.50 |
| UNASSIGNED | 1.00 | 12.50 |
Group directly attributed compute by team tag
ALTER SESSION SET TIMEZONE = 'UTC';
SELECT COALESCE(NULLIF(TRIM(query_tag), ''), 'UNASSIGNED') AS cost_bucket,
SUM(credits_attributed_compute) AS execution_credits
FROM snowflake.account_usage.query_attribution_history
WHERE warehouse_name = 'BI_WH'
AND start_time >= DATEADD(day, -8, CURRENT_DATE())
AND start_time < DATEADD(day, -1, CURRENT_DATE())
GROUP BY 1
ORDER BY execution_credits DESC, cost_bucket;What to expect and why
Use approved access and replace BI_WH with your standard shared warehouse. This example assumes each tag value is a single approved team label. For the eight-credit fixture it would find 3, 1 and 1 credits in the three query buckets. Add the separate idle bucket and any explicit reconciliation residual from the same closed reporting period.
Check your understanding
Choose an answer, then check your reasoning. This is practice, not a scored test.
Try it yourself
Operations identifies the untagged query. Set its tag to OPERATIONS and predict the updated amounts.
Compare your reasoning
Finance stays at 3, Operations rises to 2, and shared idle remains 3. The total is still 8. The three shares are 37.5%, 25% and 37.5%.
Connect this lesson to the learning path
Official sources and curriculum
Module 16 · See module scope
By Rohit Ray · Independent educational lesson · Explore this visual lab