cancel
Showing results for 
Search instead for 
Did you mean: 
Administration & Architecture
Explore discussions on Databricks administration, deployment strategies, and architectural best practices. Connect with administrators and architects to optimize your Databricks environment for performance, scalability, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to allocate costs per SQL query?

riturralde-p
New Contributor II

By using System Tables (systen.billing.usage) I'm able to identity DBU usage per query, but I'm not able to identify who ran each query because is not part of the table. 

I'm also aware of query history where all the queries and who ran them is listed.

I was thinking if it might possible to combine both to get DBU usage per user, of if you know any other way to achieve same result.

I'll greatly appreciate it.

2 REPLIES 2

Kaniz_Fatma
Community Manager
Community Manager

Hi @riturralde-p, Yes, you can achieve this by joining the system.billing.usage table with the query history table. The query history table contains the query_id and user fields, and the system.billing.usage table contains the query_id and dbu_used fields. You can join these two tables on the query_id field to get the dbu_used per user.

riturralde-p
New Contributor II

thanks @Kaniz_Fatma for the reply, however query_id is not part of the system.billing.usage table, so no way to join them by IDs. What my Databricks account team suggested me is to join them by timestamps since both tables contain a column like that.

Also, I had to request the enablement of the Query History system table as it is still in private preview as of now.

BTW - I'm user of Azure Databricks, and if you look at AWS or GCP ones that might be the reason why you see different columns in system tables. could be the reason?.

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you won’t want to miss the chance to attend and share knowledge.

If there isn’t a group near you, start one and help create a community that brings people together.

Request a New Group