Hey,
I really think this itโs not possible to directly determine the cost of a single cell in Databricks.
However, you can approach this in two ways, depending on the type of cluster youโre using, as different cluster types have different pricing models:
Using the cluster cost:
For all-purpose (interactive) clusters, Databricks charges per DBU/hour based on the instance type and autoscaling settings. You can estimate the cost by looking at how long the cluster was running while the cell was being executed and then calculating the cost based on the DBU rate.
For job clusters, costs are usually lower since youโre only charged for the duration of the job. If youโre using this type of cluster, you can break down the total cost based on the runtime of the job that includes the cell.
For serverless clusters, the cost is based on dynamically allocated resources, making it a bit trickier to estimate costs accurately. In this case, checking execution logs and usage metrics could help provide better insights.
Pricing calculator
Running the notebook as a job with System Tables enabled:
If you run your notebook as a job and have System Tables enabled, you can query the system.jobs_run_cost table to get the total cost of the job.
If you find this answer helpful, feel free to mark it as resolved or give it a ๐!
๐