#7097·growthbook

[Bug] Funnel metrics spanning 3+ fact tables fail on ClickHouse (UNKNOWN_IDENTIFIER from m.* across multiple joins)

Author: johnbaconCreated Sep 22, 2026Updated Sep 23, 2026

Summary

On ClickHouse, a funnel metric (new in 5.1) whose steps span 3 or more fact tables fails every time. The generated experiment query builds __unitMetricsBase with SELECT m.*, m1.…, m2.… across two or more LEFT JOINs. ClickHouse's analyzer then names m's columns m.variation, m.<unit id>, etc., so the downstream r.* / m.variation references fail with UNKNOWN_IDENTIFIER. Funnels spanning 1–2 fact tables (0–1 joins) work.

The snapshot still reports success; the funnel's query is failed and the metric is just missing from results, so it's easy to miss.

Environment: GrowthBook Cloud (5.1), ClickHouse 26.3.16.10001.altinitystable (analyzer on by default).

Minimal reproduction (no tables needed)

This mirrors the shape of the generated query:

sql
WITH
__userMetricAgg  AS (SELECT 'a' AS variation, 'u1' AS unit_id),
__userMetricAgg1 AS (SELECT 'a' AS variation, 'u1' AS unit_id, [1] AS m0_step_1_arr),
__userMetricAgg2 AS (SELECT 'a' AS variation, 'u1' AS unit_id, [2] AS m0_step_2_arr),
__unitMetricsBase AS (
  SELECT m.*, m1.m0_step_1_arr AS m0_step_1_arr, m2.m0_step_2_arr AS m0_step_2_arr
  FROM __userMetricAgg m
  LEFT JOIN __userMetricAgg1 m1 ON (m1.unit_id = m.unit_id)
  LEFT JOIN __userMetricAgg2 m2 ON (m2.unit_id = m.unit_id)
),
__funnelResolve_1 AS (SELECT r.* FROM __unitMetricsBase r)
SELECT r.variation, COUNT(*) AS users FROM __funnelResolve_1 r GROUP BY r.variation
Code: 47. DB::Exception: Identifier 'r.variation' cannot be resolved from subquery with name r. … Maybe you meant: ['m.variation']. (UNKNOWN_IDENTIFIER)

In the full generated query the same thing surfaces as Unknown expression identifier 'variation'.

  • Remove __userMetricAgg2 and its join (one join only): succeeds.
  • Keep both joins but select m's columns explicitly (m.variation AS variation, m.unit_id AS unit_id, …) instead of m.*: succeeds.

Expected Behavior

A funnel whose steps use 3+ fact tables from the same data source runs on ClickHouse, as the docs describe ("Each step selects its own Fact Table, so a funnel can move between tables").

Current Behavior

The funnel query fails with UNKNOWN_IDENTIFIER whenever __unitMetricsBase has two or more joins. Snapshot status stays success, and the metric silently drops out of results.

Suggested fix

In the ClickHouse funnel SQL, have __unitMetricsBase project the base aggregate's columns explicitly with aliases (variation, unit id, timestamp, dimension columns, m0_step_0_resolved_ts, …) instead of m.*. Surfacing a failed metric query on the snapshot or results page would also help.

Workaround

Union the events into a single fact table with an event-type column and filter each step on it, so each funnel needs at most one join.