Timbr Measures vs. Custom SQL Aggregations in Databricks

7 minutes reading
  • Databricks supports measures through ad-hoc SQL, Spark, and Delta Live Tables—but these can be complex and hard to manage at scale.
  • Timbr offers a smarter approach with automatic semantic measure generation, measure composability, and a cost-performance optimized cache.
  • This blog compares SQL-based aggregations in Databricks and Timbr measures

Introduction

Measures are the foundation of trusted analytics. They define how teams calculate revenue, sales, costs, customer value, risk, usage, and other business-critical KPIs. When measures are inconsistent, every dashboard, notebook, AI agent, and business team can end up working from a different version of the truth.

Databricks provides strong native capabilities for defining and governing measures through SQL, notebooks, Unity Catalog, Metric Views, materialized views, and data engineering workflows. These options give data teams flexibility and control inside the lakehouse.

Timbr extends this foundation with ontology-based measures. Instead of treating measures as isolated SQL expressions or table-level calculations, Timbr connects them to business concepts, relationships, hierarchies, and rules. This makes measures reusable across Databricks workflows, BI tools, applications, and AI agents – and across the broader business ecosystem when data spans more than Databricks.

This article compares native Databricks approaches to measures with Timbr’s ontology-based approach, focusing on governance, reuse, business context, and AI readiness.

Understanding Measures and Their Role in Data-Driven Decision Making

Measures are quantitative metrics defined over data stores (e.g. SUM(sales), AVG(revenue), etc.) and serve as the foundation of analytics, reporting, and machine learning (ML).

Measures are essential for:

  • Decision Making: Providing trusted KPIs for business planning.
  • Consistency and Trust: Ensuring uniform metrics across teams to avoid discrepancies.
  • Powering AI and Agent Workflows: Measures give AI systems approved business definitions to use when answering natural language questions or generating SQL.

Measures’ key challenges include:

  • Inconsistent Definitions: Different teams defining “total sales” in conflicting ways, undermining trust.
  • Scalability: Managing metrics across projects without duplication.
  • Performance: Delivering consistent query performance across dashboards, notebooks, and AI workflows.
  • AI Readiness: Preparing metrics for LLM-driven insights with rich metadata.

Databricks and Timbr address these challenges, but their approaches differ in automation, governance, and usability, impacting time to value and enterprise scalability.

How are Measures Created in Databricks?

Databricks offers several flexible ways to define measures, including SQL queries, views, materialized views, Spark DataFrames, Delta Live Tables, and Unity Catalog Metric Views. These approaches give data teams strong control over how measures are created, optimized, and governed inside the lakehouse.

1. SQL Queries and Views

The simplest approach is defining measures as SQL aggregations in Databricks SQL or notebooks. For example:

				
					sql
SELECT SUM(quantity * price) AS total_sales_amount
FROM sales;
				
			

This can be saved as a view for reuse:

				
					sql
CREATE VIEW total_sales_view AS
SELECT SUM(quantity * price) AS total_sales_amount
FROM sales;

				
			

2. Materialized Views

For improved performance, materialized views store precomputed results as Delta tables:

				
					sql
CREATE MATERIALIZED VIEW total_sales_mv
AS SELECT SUM(quantity * price) AS total_sales_amount
FROM sales;

				
			

These are updated via DLT or manual refreshes, reducing query latency for dashboards.

3. Spark DataFrames

Programmatic measures are defined using Spark DataFrames in Python or Scala, offering flexibility for complex logic:

				
					python
from pyspark.sql import SparkSession
spark = SparkSession.builder.appName("Measure").getOrCreate()
df = spark.table("sales")
total_sales_df = df.agg({"quantity * price": "sum"}).withColumnRenamed("sum(quantity * price)", "total_sales_amount")
total_sales_df.write.mode("overwrite").saveAsTable("total_sales_measure")

				
			

4. Delta Live Tables (DLT)

DLT enables real-time or incremental measure computation, ideal for streaming data:

				
					sql
CREATE LIVE TABLE total_sales_measure
AS SELECT SUM(quantity * price) AS total_sales_amount
FROM LIVE.sales;

				
			

How Timbr Creates Measures on Databricks?

Timbr formalizes measures as governed semantic objects inside the ontology. Measures are connected to business concepts, relationships, hierarchies, and rules, so they can be reused consistently across Databricks notebooks, SQL endpoints, BI tools, APIs, and AI agents.

1. Automatically Generated Measures

Timbr can automatically generate measures during ontology creation by inferring aggregations from data sources (e.g., Databricks Delta tables). For a sales_orders concept, Timbr might propose:

This automation, enabled through no-code or semi-automatic ontology generation, scans numeric columns to suggest measures like sums or counts, significantly reducing setup time.

2. Manual Measure Definition

Manual measures are defined using CREATE MEASURE:

				
					sql
CREATE OR REPLACE MEASURE total_sales_amount DECIMAL(38,2)
AS SELECT SUM(quantity * price)
				
			

3. Programmatic Creation of Measures

Timbr supports JPype, JayDeBeAPI, SQLAlchemy, Spark, Python, R, Scala, and Java, enabling ML pipelines

4. Measures inherited from top-level concepts:

Timbr’s ontology supports inheritance, allowing measures to be reused across concept hierarchies:

				
					sql
CREATE OR REPLACE MEASURE total_instrument_value DECIMAL(38,2)
AS SELECT SUM(value);

CREATE OR REPLACE CONCEPT security INHERITS (financial_instrument);
SELECT SUM(`measure.total_instrument_value`) FROM dtimbr.security;
				
			

How Databricks and Timbr Optimize Measures Performance?

Databricks Measures Performance

For performance optimization, Databricks relies on manual optimization through user-controlled techniques:

  • Decision Making: Providing trusted KPIs for business planning.
  • Materialized Views: Precompute results for low latency.
  • Delta Lake Caching: Stores data in memory/disk.
  • Query Result Caching: Temporary caching in SQL endpoints.
  • Z-Order Indexing: Optimizes data access:
  • Adaptive Query Execution (AQE): Dynamically optimizes query plans.
  • Photon Engine: Vectorized execution accelerates SQL workloads.

Strengths: Transparent, configurable, supports streaming via DLT.

Weaknesses: No pre-aggregations, and manual indexing requires expertise, increasing operational overhead.

Timbr Measures Performance

Timbr automates performance with its four-tier cache (DB, Datalake, SSD, In-memory) and query optimizations :

  • Query Optimization: Intelligent routing and rewriting enhance efficiency .
  • Cache Invalidation: Supports incremental update based on table refreshness

Strengths: Automated, reduces compute costs for repetitive queries, business-friendly.

Weaknesses: Requires approval – human in the loop.

Performance Comparison

Timbr’s automated four-tier cache excels for repetitive queries (e.g., dashboards), delivering instant results without user intervention. Databricks’ manual optimizations provide control and flexibility, ideal for streaming or ad-hoc workloads, but demand setup and expertise. 

Using Databricks and Timbr Measures to Power LLMs

Databricks integrates with LLMs through SQL endpoints and governed metadata, but without an ontology layer, query accuracy depends on how well the LLM can infer business meaning from raw schemas.

While Databricks offers ML and streaming strengths, Timbr stands out for automated, reusable measures and an LLM-ready semantic layer that simplifies query generation and boosts business user accessibility.

Governance and Scalability Considerations

Databricks Measures Governance and Scalability

Governance is managed via Unity Catalog, offering metadata, access control, and lineage. Measures, as tables or views, lack semantic context, leading to ad-hoc governance. Scalability requires manual reuse across projects, risking inconsistencies and duplication.

Timbr Measures Governance and Scalability

Measures are governed entities within the ontology, enriched with business rules and relationships . Integration with Unity Catalog ensures enterprise-grade governance. Scalability is enhanced by inheritance and automatic measure generation, enabling reuse across departments. Auditable lineage via the ontology ensures trust and compliance.

Governance and Scalability Comparison

Timbr’s semantic governance and reusability minimize duplication and ensure consistency, while Databricks’ external governance is less integrated, posing challenges for enterprise-wide alignment.

In Summary, how Databricks’ SQL Aggregations and Timbr Measures on Databricks Compare?

Databricks provides engineers with flexibility through various methods to define and manage metrics, including SQL, Spark, and Delta Live Tables (DLT). In contrast, Timbr simplifies this process by unifying metric creation through a single CREATE MEASURE syntax and automatically generating derived metrics, reducing complexity and setup time. This streamlined approach makes Timbr more accessible for data teams seeking efficiency without sacrificing capability.

Timbr also stands out in terms of reusability and semantic simplicity. Its inheritance model allows metrics and logic to be reused across the data model, minimizing duplication. In comparison, Databricks often requires engineers to manually replicate definitions across contexts. Moreover, Timbr’s ontology-based semantic layer enables users to write no-join queries that are easy for business users to understand, while Databricks users must manually handle joins and relationships.

While both platforms support Python and Spark for programmatic and machine learning access, Databricks shines in low-level ML customization, whereas Timbr adds value with higher-level, semantic ML pipelines that leverage the graph structure and ontology-driven design.

Comparison Table

Criteria Databricks Timbr
Definition Measures and aggregations can be defined through SQL, Spark, Delta Live Tables, materialized views, and Metric Views. Measures are governed semantic objects defined through CREATE MEASURE or CREATE CUBE and connected to ontology concepts.
Automatic Generation Measure definitions are typically created and managed by data teams using Databricks-native tools. Timbr can infer and generate measures during ontology creation, with options for manual refinement.
Storage Measures may be stored as queries, views, materialized views, Delta tables, or Metric Views in the Databricks environment. Measures are managed as part of the semantic model, with optional four-tier caching across DB, data lake, SSD, and in-memory layers.
Execution Queries execute through Databricks SQL, Spark, notebooks, and related Databricks compute services. Timbr translates semantic queries to Databricks SQL and executes them through the connected Databricks environment.
Inheritance Support Measure reuse is supported through Databricks assets and workflows, but concept-level inheritance is not native. Measures can be inherited across concept hierarchies using Timbr’s ontology model.
Semantic Layer Databricks provides native semantic and governance capabilities through Unity Catalog, Metric Views, and related services. Timbr provides an ontology-based semantic layer with concepts, relationships, measures, inheritance, and no-join querying.
Query Simplicity Users may still need to understand tables, joins, and metric logic depending on how the model is built. Users query governed concepts and measures through Timbr virtual schemas without manually writing joins.
Reusability Reusable views, tables, Metric Views, and governed assets can be created inside Databricks. Measures and business logic are reusable across concepts, BI tools, notebooks, applications, APIs, and AI agents.
UI Support Databricks provides SQL, notebooks, dashboards, Catalog Explorer, and governance interfaces. Timbr provides UI-based ontology modeling, no-code measure creation, graph exploration, and semantic model management.
Integration with BI Tools Strong BI integration through SQL endpoints and Databricks-native connectivity. Strong BI integration through Timbr semantic concepts, cubes, SQL access, and governed measures.
Integration with AI and LLMs Can support AI and natural language workflows through Databricks-native services and governed metadata. Exposes ontology-grounded concepts, relationships, and measures to AI agents, NL2SQL workflows, OpenAPI, LangChain, and LangGraph.
Performance Optimization Uses Databricks optimization capabilities such as materialized views, Delta caching, query result caching, Z-ordering, AQE, and Photon. Uses Timbr query optimization and optional four-tier caching, with execution pushed down to Databricks when relevant.
Governance Unity Catalog supports metadata, access control, lineage, and governed data assets. Timbr aligns ontology governance with Unity Catalog while adding semantic governance for concepts, relationships, measures, and rules.
Cross-System Context Best suited when the relevant data and governance context are managed inside Databricks. Timbr’s ontology can span Databricks and the broader business ecosystem through virtualization.
Use Case Lakehouse analytics, engineering workflows, AI workloads, governed metrics, streaming, and custom ML. Governed semantic analytics, reusable measures, no-join querying, cross-system business context, and AI-ready consumption.
Learning Curve Requires familiarity with SQL, Spark, Databricks workflows, and governance patterns. Requires familiarity with Timbr SQL and ontology concepts, while simplifying business-level querying.
Extensibility Highly extensible through Spark, SQL, Python, Scala, notebooks, and Databricks services. Highly extensible through SQL, Python, R, Scala, Java, APIs, BI tools, and AI frameworks.

Conclusion

Databricks gives data teams flexible and powerful ways to define measures inside the lakehouse. SQL, Spark, Delta Live Tables, materialized views, Unity Catalog, and Metric Views all help teams create governed metrics for analytics and AI workflows.

Timbr extends this foundation with ontology-based measures. By connecting measures to business concepts, relationships, hierarchies, and rules, Timbr makes metric logic easier to reuse across Databricks workflows, BI tools, applications, and AI agents. Teams can define business meaning once and make it available wherever governed analytics or AI consumption happens.

The difference is not whether measures can be created in Databricks. They can. The difference is how far those measures need to go. When metrics need to stay consistent across domains, tools, teams, AI agents, and the broader business ecosystem, Timbr adds the ontology-based context layer that keeps measures connected to how the business actually works.

Together, Databricks and Timbr help organizations combine lakehouse-scale data processing with governed business meaning, giving technical and business teams a more consistent foundation for analytics, decision-making, and AI-driven consumption.

Timbr Product Overview

Learn How Timbr Stacks Up Against Palantir Foundry

Partner programs enquiry

The information you provide will be used in accordance with the terms of our

privacy policy.

Schedule Meeting

Talk to an Expert

Your PDF Is On Its Way!

We’ve emailed the PDF to the address you provided.

If you don’t see it in a couple of minutes, please check your Promotions or Spam folder.

Thank You!

Our team has received your inquiry and will follow up with you shortly.

In the meantime, we invite you to watch demo and presentation videos of Timbr in our Youtube channel: