Databricks adds beta tools for AI agents to combine business metrics
Query-time joins protect governed calculations from duplicated rows. Relationship constraints help agents discover how metrics connect, while analysts still need to choose the right grouping.
Databricks’ beta capabilities let analysts and AI agents combine governed metric views at query time, while keeping metric definitions separate from the questions being asked. That could reduce the need to build one oversized semantic model for every analysis, but it does not make joined results universally additive: grouping choices still matter, and some metric-view definitions cannot be used as join inputs. SQL joins inside a metric view’s own source definition remain on the roadmap.
01
In Databricks’ example, a regional join expands two sales across three support tickets; MEASURE() returns the correct sales total of 300 instead of 900.
02
Modelers define relationship constraints in Unity Catalog with SQL informational constraints, which agents and BI tools can use to discover join paths.
03
Metric views with one-to-many joins in their YAML definitions are excluded, including when reached through composed metric views; those results must be preaggregated.
Databricksintroducedtwo beta capabilities in Unity Catalog Semantics on December 3: query-time joins and relationship constraints. The company says they let AI agents and business intelligence tools combine separately governed business metrics in SQL, while protecting calculations from inflation caused by duplicated rows.
The building block is a metric view: a table-like object containing ordinary fields, such as region, alongside defined business calculations called measures. A measure carries both its calculation and the identity of the source rows behind it. That gives the engine information it needs to avoid counting a source row repeatedly.
Previously, a metric view had to stand alone in a SQL query’s FROM clause, which identifies the data being queried. Query-time joins remove that restriction. A user or agent can now combine a metric view with another metric view, an ordinary table or a view, without changing the governed metric definition.
How a sales total becomes three times too large
Databricks illustrates the problem with sales and support tickets. Its example has two sales in the East region, totaling 300, and three tickets. Joining the records by region matches each sale with every ticket, producing six rows. An ordinary SUM over those rows returns 900 because each sale appears three times.
Using MEASURE() instead evaluates the defined sales measure over the original contributing sales rows. Databricks’ documented example returns 300 for sales and three tickets. The protection works per output group and does not require a declared primary key, the identifier commonly used to distinguish records.
That safeguard does not make every result additive. In another documented query, grouping by sales channel places the same region’s tickets in both the web and store groups. Each group’s count is valid, but adding those counts does not produce the overall ticket count. The choice of grouping still matters.
Giving agents a map between metrics
Relationship constraints address a different part of the task: discovering how independently maintained metric views connect. Data modelers define those relationships in Unity Catalog using SQL informational constraints. Agents and business intelligence tools can then discover the relationships and use them to generate joins.
Databricks says this separates governance from the scope of an individual analysis. Modelers govern metric definitions and relationships, while agents combine them for new business questions. The intended benefit is avoiding a single sprawling model—or many overlapping ones—built to anticipate every combination of metrics, dimensions and filters.
Use Databricks Runtime 19 or later with query-time join support.
Have SELECT permission on every referenced metric view, table or view, plus USE CATALOG and USE SCHEMA permissions on its catalog and schema.
There are modeling restrictions, too. Metric views containing one-to-many joins in their YAML definitions cannot be inputs, including through a chain of composed metric views. The documentation directs users to preaggregate those results before joining. Measure expressions also cannot reference derived fields by name; authors must inline the underlying expression instead.
A related capability remains on the roadmap: SQL joins between metric views inside a metric view’s own source definition. Databricks labels that support “coming soon,” distinguishing it from the query-time joins now in beta.
Reader comments
Newest comments first. Replies stay oldest first.