Home › Learn › Databricks interview prep › Tagging

Databricks interview prep · data engineering

Tagging: best practices and how organizations use tags

The four kinds of tags, how organizations use them for cost, ownership, classification and automation, and the practices that keep them useful.

Maintenance commandsRow-level securityCompute choiceJoinsSkew and shuffleAQE, Photon, POCost and performance leversDeclarative and semanticAsset BundlesLakeflow ConnectUniFormVector Searchdbt and ODCSEgress and ingressMaintenance in picturesClustering and compactionMaintenance strategySlow writesBackup and recoveryTaggingQuestion bank

Defaults, limits and preview status change often. Check the current Databricks docs before quoting a number.

Policy forces tags atcreationCompute, jobs, warehousesand serverless carry themTags flow to Azure costdata and system tablesDashboards, alerts andchargeback

Tag once at creation, and the rest follows.

Tag limits and propagation details vary by cloud; check the current Databricks and Azure documentation.

Kinds of tag

Four different things called tags

KindWhereUsed for
Compute tagsClusters, pools, jobs, SQL warehouses, pipelinesCost attribution; they propagate to cloud resources and appear in billing records (system.billing.usage)
Budget or usage policy tagsServerless computeThe only way to attribute serverless spend
Cloud resource tagsAzure workspace, resource groups, storage accountsAzure Cost Management, ownership, environment
Unity Catalog tags (including governed tags)Catalogs, schemas, tables, columnsClassification (PII, sensitivity), domain, certification; can drive access policies and discovery

Keep the two worlds apart: cost tags answer “who pays”, governance tags answer “what is this data and who may see it”.

How organizations use them

The common uses

UseExample tagsEnforced by
Chargeback and showbackcost_center, team, projectCluster policy, budget policy, Azure Policy
Environment separationenvironment = dev / test / prodBundles set it per target
Ownership and on-callowner, contact, data_productPolicy requires it; alerts route by it
Budgets and anomaly alertscost_center, projectBudget alerts on tag totals
Workload typeworkload = etl / bi / ml / adhocJobs and warehouses set it
Automationmaintenance_tier = hot / warm / coldMaintenance job reads the tag
Data classificationclassification = pii / confidentialGoverned tags, masks and policies
Lifecycle and cleanupexpires_on, created_byA cleanup job finds stale resources
Compliance and auditregulated = true, retentionReports from system tables

Best practices

What works

PracticeWhy
A small mandatory set (about five keys)Teams will fill in five tags and ignore fifteen
Fixed keys and controlled valuesFree text produces cost-center, CostCenter and costcenter
Enforce at creation, not afterwardsCluster policies set or require tags; budget policies for serverless; Azure Policy for resources
Set them in codeBundles and Terraform fill tags so nobody types them
Tag the job, not just the clusterShared and pooled compute otherwise hides who used it
Plan for shared computeDecide how to split shared all-purpose clusters and pools (by user, by usage)
Tags are not retroactivePast usage stays untagged; start early
Watch untagged spendA dashboard and alert on usage with missing tags
No secrets or personal data in tagsTags are visible in billing and APIs
Showback before chargebackShow teams their cost for a quarter before charging it
Document the taxonomy and review itKeys and values drift as the organization changes
Respect limitsCloud resources have a maximum number and length of tags
-- spend by team and environment, last 30 days
SELECT custom_tags['team'] AS team, custom_tags['environment'] AS env,
       SUM(usage_quantity) AS dbus
FROM system.billing.usage
WHERE usage_date >= date_sub(current_date(), 30)
GROUP BY 1, 2
ORDER BY dbus DESC;

Multiply by list prices from system.billing.list_prices for money. Rows with a null team are your untagged spend.

Practice

Questions to rehearse

  1. How do you attribute serverless cost to teams?
  2. How do you make sure every cluster is tagged?
  3. Cost tags versus governed tags: what is the difference?
  4. How would you charge back shared clusters?
  5. What would you do about the untagged spend you find on day one?
In an interview, say: A small mandatory taxonomy, enforced by policy at creation, set by code, and watched through system tables.

FAQ

Questions people ask

Can I tag after the fact?

Yes, but past usage stays untagged.

Do tags work for serverless?

Use budget or usage policies to attach tags to serverless usage.

Next

Where to go next

All Databricks interview topics · All data engineering · Databricks on this site