Home / Databricks on Azure

Databricks on AzureTroubleshootingIntermediate

METRIC_VIEW_WINDOW_MEASURE_REFERENCES_WINDOW_MEASURE - fixing metric views after the June 2026 Databricks validation change

Since 29 June 2026, Databricks Runtime 17.3 LTS, 18 LTS and 18.2 reject metric views whose window measures reference other window measures. Rewrite the measure to reference base measures, and only use the opt-out flag as a temporary bridge.

Deepak Bhardwaj3 min read

Applies toUnity Catalog metric views on Azure Databricks; Databricks Runtime 17.3 LTS, 18 LTS, 18.2 and Databricks SQL; window measures (running totals, period-over-period)

What changed

From the Databricks Runtime maintenance updates (29 June 2026, 17.3 LTS, 18 LTS and 18.2):

  • Metric views now reject window measures that reference other window measures.
  • The error is METRIC_VIEW_WINDOW_MEASURE_REFERENCES_WINDOW_MEASURE.
  • The check can be turned off with spark.databricks.sql.metricView.rejectWindowOnWindowMeasure.enabled = false.

Earlier in 2026 (18 May), Databricks also fixed window measures returning wrong results with GROUP BY, IN/BETWEEN filters and mixed predicates on the order column. Taken together: window measures on top of window measures were an area where results could be wrong, and the platform now stops you building them.

Example of what's now rejected

version: 0.1
source: main.sales.orders
dimensions:
  - name: order_date
    expr: order_date
measures:
  - name: revenue
    expr: SUM(amount)
  - name: revenue_running_total          # window measure
    expr: MEASURE(revenue)
    window:
      - order: order_date
        range: cumulative
        semiadditive: last
  - name: revenue_running_total_7d_avg   # window measure on a window measure -> rejected
    expr: MEASURE(revenue_running_total)
    window:
      - order: order_date
        range: trailing 7 day
        semiadditive: last

(The YAML shape follows the metric view specification; field names can differ slightly between spec versions. Use the version your workspace documents.)

1. Find affected views

Views fail when they're created or altered, and queries against existing views may fail on the newer runtimes. List metric views and check their definitions:

SELECT table_catalog, table_schema, table_name
FROM system.information_schema.tables
WHERE table_type = 'METRIC_VIEW';

For each, SHOW CREATE TABLE (or open it in Catalog Explorer) and look for window measures whose expr uses MEASURE() of another window measure.

2. Rewrite

Make each window measure reference base (non-window) measures only. For the example above, compute the 7-day trailing average directly from the base measure:

  - name: revenue_7d_avg
    expr: MEASURE(revenue) / 7
    window:
      - order: order_date
        range: trailing 7 day
        semiadditive: last

If the business really needs "a window over a window" (for example, the average of a running total), do it in the query that reads the metric view, or in a downstream table where the logic is explicit and testable:

WITH daily AS (
  SELECT order_date, MEASURE(revenue_running_total) AS running_total
  FROM main.sales.orders_metrics
  GROUP BY order_date
)
SELECT order_date,
       AVG(running_total) OVER (ORDER BY order_date ROWS BETWEEN 6 PRECEDING AND CURRENT ROW) AS running_total_7d_avg
FROM daily;

3. Check numbers against a reference

Because results of these measures could be wrong before the May fix, compare the rewritten measures with an independent SQL calculation for a few dates and filter combinations before publishing them to dashboards and Genie spaces.

4. The opt-out flag

SET spark.databricks.sql.metricView.rejectWindowOnWindowMeasure.enabled = false;

Use it only to keep a critical dashboard running for a few days while you rewrite. It turns off a check that exists because these results weren't reliable.

Checklist

  • Metric views with window-on-window measures identified
  • Window measures rewritten to reference base measures only
  • Window-over-window logic moved to queries or downstream tables
  • Results compared with independent SQL
  • Opt-out flag removed (if used)

Sources