Latest
Databricks adds query-time joins for AI agents in Unity Catalog
Image: Databricks

Databricks adds query-time joins for AI agents in Unity Catalog

Chat about this article with your favourite AI tool

Databricks has introduced two new capabilities in Unity Catalog Semantics, query-time joins and relationship constraints, designed to let AI agents answer questions across separately governed business metrics. Both are now in Beta.

The company said traditional semantic models assume the scope of analysis is known when the model is built. AI agents break that assumption, because users can ask questions spanning sales, support tickets and product usage, even when different teams own each metric. Covering every combination in advance would mean either oversized semantic models or many overlapping ones, according to Databricks.

Databricks logo alongside a diagram of metric views in Unity Catalog
Image: Databricks

Joins that do not inflate metrics

Metric views, which Databricks released in April as a SQL-first way to define and govern business metrics, previously had to sit alone in a query’s FROM clause. They can now be joined with other metric views, tables and views in ordinary SQL.

The main promise is protection against a familiar analytics error. Joining a sales table to a support-ticket table by region can duplicate rows and produce inflated totals, a problem known as a chasm trap. Databricks said its SQL engine now prevents this: each source row contributes to a measure at most once per group, across one-to-many, many-to-one and many-to-many joins.

In the company’s example, a region with two sales and three tickets yields six joined rows. A standard SUM over the amount returns 900 instead of the correct 300, while the governed measure, evaluated through the MEASURE() function, returns 300. Databricks said a primary key is not required for this to work.

Query-time joins also allow users to enrich a metric view with outside dimensions, such as a geography table, combine measures from different metric views in one expression, and use fields from one metric view to filter measures in another. Databricks said this extends to outer joins, HAVING clauses, and EXISTS and IN subqueries.

Relationship constraints

The second feature lets data modelers declare how metric views relate to each other directly in Unity Catalog. A relationship constraint is a named, directional link with a declared cardinality (one-to-one, many-to-one or many-to-many) and a flexible join condition.

The relationships appear in DESCRIBE TABLE EXTENDED and in information_schema.table_constraints. Agents and BI tools can read them and write the joins themselves, so no combined semantic model has to be defined beforehand.

Databricks distinguished these from definition-time joins in a metric view’s YAML, which fix a single join path. Relationship constraints describe possible joins and leave the choice to the agent or user, which suits role-playing dimensions such as shipping and billing cities, self-relationships and cycles. The company said it plans to add instructions for role-playing dimensions and path ambiguity.

Genie and BI tool integration

Databricks said Genie Ontology, which treats metric views as the authoritative definitions of business metrics, can now discover how they relate. Genie One, Genie Agents and Genie Code can use both features, and AI/BI Dashboards can import relationships from Unity Catalog and publish ones authored in dashboards back to it.

For third-party BI tools, the company said they can keep generating their own SQL for operations such as Top N filters and cross-filtering while Databricks evaluates governed measures. In Tableau, a calculated field wrapping MEASURE() in RAWSQLAGG_REAL can pass measures through. Power BI works through mirroring, with each metric view published as a table with matching DAX measures. Databricks said it has begun integrations with some BI vendors and expects to announce them soon.

Availability and roadmap

Both features are in Beta on Databricks Runtime 19 and above and on SQL warehouses. Support for SQL joins between metric views in a metric view’s source, enabling more flexible multi-fact definitions, is listed as coming soon.

Databricks is also working on declaring ad hoc measures directly in SQL without YAML, and on SQL extensions to control a measure’s evaluation context. It said it open-sourced the core metric view and measure reference implementation in Apache Spark and Unity Catalog last July, and contributes to the Apache Ossie (Incubating) standardization effort.

Source: Databricks Blog