Skip to main content

Attributed cost system table reference

Beta

This feature is in Beta.

This page provides an overview of the attributed cost system table, including the schema, how attributed cost is estimated, and example queries.

The attributed cost table breaks shared compute bills down to the workloads that ran on them. A SQL warehouse is billed as a single resource in system.billing.usage, so you cannot tell from the billable usage table which queries, users, or teams drove a warehouse's cost. The attributed cost table estimates each query's share of the warehouse's usage so you can identify cost drivers and charge back or show back shared costs.

Table path: This system table is located at system.billing.attributed_cost.

During Beta, the table contains records for queries run on SQL warehouses only. Each row is one query. For records from system.billing.usage that do not have attributed cost records, such as jobs or serverless notebooks, use the billable usage table directly.

Record availability​

Records are typically available within 24 hours. Data delivery for new workspaces can take longer than this.

Using the attributed cost table​

The attributed cost table includes a record for each query that ran on a SQL warehouse and consumed warehouse compute. The table includes records from all workspaces in your account that are in the same region as the workspace you use to access the table.

Each record reports active usage, which is the estimated share of the warehouse's billed usage that the query consumed while it was running. Active usage does not include unattributed time, which is the time when the warehouse was ready but had no queries running on it. Because of this, the sum of active usage for a warehouse is less than or equal to the warehouse's total billed usage in system.billing.usage. To charge back the full warehouse cost, including unattributed time, see Charge back the full warehouse cost.

By default, only admins have access to the system table. To share the table's data with a user or group, Databricks recommends creating a dynamic view for each user or group. See Create a dynamic view.

Attributed cost table schema​

The attributed cost system table uses the following schema:

Column name

Data type

Description

Example

record_id

string

Unique ID for this attributed cost record. For queries, the value is cpq_ followed by the query's statement ID.

cpq_01f1daa4-176f-11ae
-8c93-5073a9b098ca

usage_metadata

struct

System-provided metadata about the workload the cost is attributed to, grouped by product. Only the struct for the product that originated the usage is populated. See Usage metadata.

See Usage metadata

identity_metadata

struct

System-provided metadata about the identities involved in the attributed usage. See Identity metadata.

{
executed_by: example@databricks.com
}

start_time

timestamp

The start time of the workload. For queries, the time when Databricks received the request. Timezone information is recorded at the end of the value with +00:00 representing UTC.

2026-11-07T10:00:00.000+00:00

end_time

timestamp

The end time of the workload. For queries, the time the statement execution ended. Timezone information is recorded at the end of the value with +00:00 representing UTC.

2026-11-07T10:00:12.000+00:00

usage_date

date

Date of the attributed cost record, derived from end_time. Use this field for faster aggregation by date.

2026-11-07

usage_unit

string

Unit the attributed usage is measured in.

DBU

active_usage_quantity

decimal

Estimated number of units the workload consumed while it was running. For queries, this is the query's share of the warehouse's billed usage. Usage from unattributed time is not included. See How attributed cost is estimated.

0.4512

active_usage_list_cost

decimal

Estimated list-price cost of active_usage_quantity. Computed as active_usage_quantity multiplied by the SKU's list price in system.billing.list_prices (pricing.effective_list.default) in effect when the usage occurred. Expressed in the account's billing currency. Discounts and commitments are not applied.

0.3158

granular_tags

struct

Tags applied to the workload rather than to the compute resource. For queries, query_tags contains the query's query tags as a map<string, string>.

{
query_tags: {
"team": "marketing",
"cost_center": "701"
}
}

usage_record_ids

array<string>

The record_id values of the records in system.billing.usage that this attributed cost record is associated with. A workload that spans more than one billing period is associated with more than one usage record. See Join with the billable usage table.

[
"11e22ba4-87b9-4cc2-9770-d10b894b7118",
"11e22ba4-87b9-4cc2-9770-d10b894b7119"
]

account_id

string

ID of the account this report was generated for.

23e22ba4-87b9-4cc2
-9770-d10b894b7118

workspace_id

string

ID of the workspace this usage was associated with.

1234567890123456

sku_name

string

Name of the SKU, from the associated billable usage record. If the query's usage spans more than one SKU, this is the SKU with the highest list price. See How attributed cost is estimated.

ENTERPRISE_SERVERLESS_SQL_COMPUTE_US_WEST_OREGON

cloud

string

Cloud associated with this usage. Possible values are AWS, AZURE, and GCP.

AWS

billing_origin_product

string

The product that originated the usage. During Beta, the value is always SQL. For possible values, see Billing origin product reference.

SQL

custom_tags

map<string, string>

Custom tags from the associated billable usage record, such as the tags applied to the SQL warehouse.

{ "env": "production" }

Column name

Data type

Description

Example

record_id

string

Unique ID for this attributed cost record. For queries, the value is cpq_ followed by the query's statement ID.

cpq_01f1daa4-176f-11ae
-8c93-5073a9b098ca

usage_metadata

struct

System-provided metadata about the workload the cost is attributed to, grouped by product. Only the struct for the product that originated the usage is populated. See Usage metadata.

See Usage metadata

identity_metadata

struct

System-provided metadata about the identities involved in the attributed usage. See Identity metadata.

{
executed_by: example@databricks.com
}

start_time

timestamp

The start time of the workload. For queries, the time when Databricks received the request. Timezone information is recorded at the end of the value with +00:00 representing UTC.

2026-11-07T10:00:00.000+00:00

end_time

timestamp

The end time of the workload. For queries, the time the statement execution ended. Timezone information is recorded at the end of the value with +00:00 representing UTC.

2026-11-07T10:00:12.000+00:00

usage_date

date

Date of the attributed cost record, derived from end_time. Use this field for faster aggregation by date.

2026-11-07

usage_unit

string

Unit the attributed usage is measured in.

DBU

active_usage_quantity

decimal

Estimated number of units the workload consumed while it was running. For queries, this is the query's share of the warehouse's billed usage. Usage from unattributed time is not included. See How attributed cost is estimated.

0.4512

active_usage_list_cost

decimal

Estimated list-price cost of active_usage_quantity. Computed as active_usage_quantity multiplied by the SKU's list price in system.billing.list_prices (pricing.effective_list.default) in effect when the usage occurred. Expressed in the account's billing currency. Discounts and commitments are not applied.

0.3158

granular_tags

struct

Tags applied to the workload rather than to the compute resource. For queries, query_tags contains the query's query tags as a map<string, string>.

{
query_tags: {
"team": "marketing",
"cost_center": "701"
}
}

usage_record_ids

array<string>

The record_id values of the records in system.billing.usage that this attributed cost record is associated with. A workload that spans more than one billing period is associated with more than one usage record. See Join with the billable usage table.

[
"11e22ba4-87b9-4cc2-9770-d10b894b7118",
"11e22ba4-87b9-4cc2-9770-d10b894b7119"
]

account_id

string

ID of the account this report was generated for.

23e22ba4-87b9-4cc2
-9770-d10b894b7118

workspace_id

string

ID of the workspace this usage was associated with.

1234567890123456

sku_name

string

Name of the SKU, from the associated billable usage record. If the query's usage spans more than one SKU, this is the SKU with the highest list price. See How attributed cost is estimated.

ENTERPRISE_SERVERLESS_SQL_COMPUTE_US_WEST_OREGON

cloud

string

Cloud associated with this usage. Possible values are AWS, AZURE, and GCP.

AWS

billing_origin_product

string

The product that originated the usage. During Beta, the value is always SQL. For possible values, see Billing origin product reference.

SQL

custom_tags

map<string, string>

Custom tags from the associated billable usage record, such as the tags applied to the SQL warehouse.

{ "env": "production" }

Usage metadata reference​

The usage_metadata column is a struct with one nested struct per product. Only the struct for the product that originated the usage is populated. The other structs are null.

note

The usage_metadata column in this table is separate from the usage_metadata column on the associated records in system.billing.usage. To read the billable usage record's metadata, join on usage_record_ids. See Join with the billable usage table.

sql​

The usage_metadata.sql struct is populated for queries run on SQL warehouses. Its values match the corresponding columns in system.query.history for the same statement.

Value

Description

Example

statement_id

The ID that uniquely identifies the execution of the statement. Join this value to system.query.history.statement_id to get the statement's text, duration, and other details.

01f1daa4-176f-11ae
-8c93-5073a9b098ca

warehouse_id

ID of the SQL warehouse that ran the statement.

ec58ee3772e8d305

client_application

Client application that ran the statement, such as Databricks SQL Editor or Tableau.

Databricks SQL Editor

query_source

A struct that identifies the Databricks entities involved in running the statement, such as a job or dashboard. The struct has the same shape as the query_source column in system.query.history. For the meaning of each field and the valid combinations, see Query history system table reference.

{
job_info: {
job_id: 12781233243479,
job_run_id: null,
job_task_run_id: 110373910199121
},
legacy_dashboard_id: null,
dashboard_id: null,
alert_id: null,
notebook_id: null,
sql_query_id: null,
genie_space_id: null,
pipeline_info: null
}

Value

Description

Example

statement_id

The ID that uniquely identifies the execution of the statement. Join this value to system.query.history.statement_id to get the statement's text, duration, and other details.

01f1daa4-176f-11ae
-8c93-5073a9b098ca

warehouse_id

ID of the SQL warehouse that ran the statement.

ec58ee3772e8d305

client_application

Client application that ran the statement, such as Databricks SQL Editor or Tableau.

Databricks SQL Editor

query_source

A struct that identifies the Databricks entities involved in running the statement, such as a job or dashboard. The struct has the same shape as the query_source column in system.query.history. For the meaning of each field and the valid combinations, see Query history system table reference.

{
job_info: {
job_id: 12781233243479,
job_run_id: null,
job_task_run_id: 110373910199121
},
legacy_dashboard_id: null,
dashboard_id: null,
alert_id: null,
notebook_id: null,
sql_query_id: null,
genie_space_id: null,
pipeline_info: null
}

Identity metadata reference​

The identity_metadata column records the identities involved in the attributed usage. The executed_by field is the email address or username of the user or Databricks service principal that ran the workload. For queries, this matches executed_by in system.query.history.

The identity_metadata column in this table is separate from the identity_metadata column in system.billing.usage. For SQL warehouse usage, system.billing.usage records the warehouse owner in identity_metadata.owned_by, whereas this table records the user who ran each query.

How attributed cost is estimated​

Attributed cost is an estimate. Databricks does not meter individual queries. Instead, the attributed cost table splits each warehouse's billed usage across the queries that ran on it:

  1. For each billing period of a warehouse in system.billing.usage, Databricks identifies the queries that ran on that warehouse during the period.
  2. The billed usage of the period is split across those queries in proportion to the compute each query consumed, based on the query's task execution time. Queries that span more than one billing period receive a share of each period they ran in.
  3. A query's share is capped at the usage of a single cluster for the duration of the query. A query runs on one cluster of a warehouse, so its attributed usage doesn't exceed what that cluster consumed while the query ran, even on multi-cluster warehouses.
  4. Usage from unattributed time is not assigned to any query. It remains part of the warehouse's billed usage in system.billing.usage but does not appear in this table.

If a warehouse is billed under more than one SKU in the same billing period, the query receives a share of each SKU's usage. active_usage_quantity is the total across those SKUs, and active_usage_list_cost prices each SKU's share at that SKU's list price, so the cost is a blend of the SKUs' rates. Because a record has a single sku_name, it reports the SKU with the highest list price.

As a result:

  • active_usage_quantity summed across all queries on a warehouse is less than or equal to the warehouse's usage_quantity in system.billing.usage for the same period. The difference is the usage from unattributed time.
  • The same query can have a different attributed cost on a different day, because its cost depends on what else ran on the warehouse at the same time.
  • Queries that do not consume warehouse compute, such as queries served from the query result cache, do not have records in this table.

Join with the billable usage table​

Each attributed cost record is associated with one or more records in system.billing.usage through usage_record_ids. A query that runs within a single billing period has one associated usage record. A query that spans a billing period boundary has one usage record per period.

To join the two tables, explode the array:

SQL
SELECT
a.record_id,
a.statement_id,
a.active_usage_quantity,
u.record_id AS usage_record_id,
u.usage_start_time,
u.usage_end_time,
u.usage_quantity AS warehouse_usage_quantity
FROM (
SELECT
record_id,
usage_metadata.sql.statement_id,
active_usage_quantity,
explode(usage_record_ids) AS usage_record_id
FROM system.billing.attributed_cost
WHERE usage_date = current_date() - 1
) a
JOIN system.billing.usage u ON u.record_id = a.usage_record_id

Sample queries​

The following queries show common ways to use the attributed cost table. For sample queries against the billable usage table, see Monitor costs using system tables.

Which queries were the most expensive this month, and who ran them?​

SQL
SELECT
a.usage_metadata.sql.statement_id,
a.identity_metadata.executed_by,
a.usage_metadata.sql.warehouse_id,
a.active_usage_quantity,
a.active_usage_list_cost,
q.statement_text
FROM system.billing.attributed_cost a
LEFT JOIN system.query.history q
ON q.statement_id = a.usage_metadata.sql.statement_id
AND q.workspace_id = a.workspace_id
WHERE a.usage_date >= date_trunc('MONTH', current_date())
ORDER BY a.active_usage_quantity DESC
LIMIT 10

How much did each user spend on SQL warehouses this month?​

SQL
SELECT
identity_metadata.executed_by,
SUM(active_usage_quantity) AS active_dbus,
SUM(active_usage_list_cost) AS active_list_cost
FROM system.billing.attributed_cost
WHERE usage_date >= date_trunc('MONTH', current_date())
GROUP BY 1
ORDER BY active_dbus DESC

How much did a team spend, based on query tags?​

This query uses the team query tag. Replace the tag key and value with your own.

SQL
SELECT
SUM(active_usage_quantity) AS active_dbus,
SUM(active_usage_list_cost) AS active_list_cost
FROM system.billing.attributed_cost
WHERE usage_date >= date_trunc('MONTH', current_date())
AND granular_tags.query_tags['team'] = 'marketing'

Which dashboards, jobs, or Genie Agents drove the most cost?​

The usage_metadata.sql.query_source struct identifies the entity that triggered each query. This query groups cost by dashboard.

SQL
SELECT
usage_metadata.sql.query_source.dashboard_id,
COUNT(*) AS queries,
SUM(active_usage_quantity) AS active_dbus,
SUM(active_usage_list_cost) AS active_list_cost
FROM system.billing.attributed_cost
WHERE usage_date >= date_trunc('MONTH', current_date())
AND usage_metadata.sql.query_source.dashboard_id IS NOT NULL
GROUP BY 1
ORDER BY active_dbus DESC
LIMIT 10

To group by a different source, replace dashboard_id with job_info.job_id, notebook_id, alert_id, sql_query_id, or genie_space_id.

How do I charge back the full warehouse cost?​

Active usage excludes unattributed time, so summing active_usage_quantity understates what the warehouse cost in total. To charge back the full bill, distribute each warehouse's total billed usage from system.billing.usage across teams in proportion to their active usage. This example attributes by the team query tag.

SQL
WITH warehouse_bill AS (
SELECT
workspace_id,
usage_metadata.warehouse_id AS warehouse_id,
SUM(usage_quantity) AS total_usage
FROM system.billing.usage
WHERE usage_date >= date_trunc('MONTH', current_date())
AND billing_origin_product = 'SQL'
AND usage_metadata.warehouse_id IS NOT NULL
GROUP BY 1, 2
),
team_active_usage AS (
SELECT
workspace_id,
usage_metadata.sql.warehouse_id AS warehouse_id,
granular_tags.query_tags['team'] AS team,
SUM(active_usage_quantity) AS active_usage
FROM system.billing.attributed_cost
WHERE usage_date >= date_trunc('MONTH', current_date())
GROUP BY 1, 2, 3
),
warehouse_active_usage AS (
SELECT workspace_id, warehouse_id, SUM(active_usage) AS total_active_usage
FROM team_active_usage
GROUP BY 1, 2
)
SELECT
t.team,
SUM(t.active_usage) AS active_usage,
SUM(t.active_usage * b.total_usage / NULLIF(w.total_active_usage, 0)) AS total_usage
FROM team_active_usage t
JOIN warehouse_active_usage w ON t.workspace_id = w.workspace_id AND t.warehouse_id = w.warehouse_id
JOIN warehouse_bill b ON t.workspace_id = b.workspace_id AND t.warehouse_id = b.warehouse_id
GROUP BY 1
ORDER BY total_usage DESC

Rows with a null team represent queries without the tag. Usage from unattributed time is split in proportion to each team's active usage on the same warehouse. For a more accurate split, group by day or by hour instead of by month.

How much of a warehouse's usage was not attributed to any query?​

SQL
WITH billed AS (
SELECT usage_metadata.warehouse_id AS warehouse_id, SUM(usage_quantity) AS billed_dbus
FROM system.billing.usage
WHERE usage_date = current_date() - 1
AND billing_origin_product = 'SQL'
AND usage_metadata.warehouse_id IS NOT NULL
GROUP BY 1
),
attributed AS (
SELECT usage_metadata.sql.warehouse_id AS warehouse_id, SUM(active_usage_quantity) AS active_dbus
FROM system.billing.attributed_cost
WHERE usage_date = current_date() - 1
GROUP BY 1
)
SELECT
b.warehouse_id,
b.billed_dbus,
COALESCE(a.active_dbus, 0) AS active_dbus,
b.billed_dbus - COALESCE(a.active_dbus, 0) AS unattributed_dbus,
ROUND(COALESCE(a.active_dbus, 0) / b.billed_dbus, 2) AS active_share
FROM billed b
LEFT JOIN attributed a ON a.warehouse_id = b.warehouse_id
ORDER BY unattributed_dbus DESC

A low active_share means that most of the warehouse's billed time was unattributed time. Consider lowering the warehouse's auto-stop setting or consolidating workloads onto fewer warehouses.