Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

refactor(experiments): pass precompute job ids to builders as inputs (#109443)

Anders193e9a0ff059
diff --git a/products/experiments/backend/hogql_queries/METRIC_EVENTS_PRECOMPUTATION.md b/products/experiments/backend/hogql_queries/METRIC_EVENTS_PRECOMPUTATION.md
index 2e31f36eef65..2b2ba43b832d 100644
--- a/products/experiments/backend/hogql_queries/METRIC_EVENTS_PRECOMPUTATION.md
+++ b/products/experiments/backend/hogql_queries/METRIC_EVENTS_PRECOMPUTATION.md
@@ -134,9 +134,10 @@ SELECT
Each daily window becomes a separate job. Already-computed windows are skipped.
-### Read path: `_build_funnel_query_legacy()`
+### Read path: `build_funnel_query_legacy()`
-When `metric_events_preaggregation_job_ids` is set, the metric_events CTE reads from the precomputed table instead of scanning events:
+When the funnel builder gets metric-events job ids, the metric_events CTE of the three-CTE path reads from the precomputed table instead of scanning events.
+The single-scan path ignores them and scans events. The funnel takes that path when its exposure select does not read precomputed exposures (`ExposureQueryBuilder.reads_precomputed()`).
```sql
metric_events AS (
@@ -158,22 +159,30 @@ metric_events AS (
### Wiring: `_get_experiment_query()`
-The runner orchestrates both precomputations:
+The runner orchestrates both precomputations, then hands the job ids to `build_query()`:
```python
-if should_precompute and not is_data_warehouse_query:
- # 1. Precompute exposures (already existed)
+if should_precompute and not self.is_data_warehouse_query and self.group_type_index is None:
result = self._ensure_exposures_precomputed(builder)
if result.ready:
- builder.preaggregation_job_ids = result.job_ids
-
- # 2. Precompute metric events (new — ordered funnels only)
- if is_ordered_funnel:
- result = self._ensure_metric_events_precomputed(builder)
- if result.ready:
- builder.metric_events_preaggregation_job_ids = result.job_ids
+ exposure_job_ids = [str(job_id) for job_id in result.job_ids]
+
+ if self._metric_events_precompute_applicable():
+ metric_result = self._ensure_metric_events_precomputed(builder)
+ if metric_result.ready:
+ metric_events_job_ids = [str(job_id) for job_id in metric_result.job_ids]
+
+return builder.build_query(
+ precomputation_context=ExperimentPrecomputationContext(
+ exposure_job_ids=exposure_job_ids,
+ metric_events_job_ids=metric_events_job_ids,
+ )
+)
```
+`build_query()` does not store the job ids on the builder.
+It builds one exposure builder with the exposure job ids and passes it, with the metric-events job ids, to the metric builder of that build.
+
Both use the same lazy computation system (daily windows, job management, TTL).
## Conversion window
@@ -206,10 +215,10 @@ Retention stores one row per event matching the start or completion predicate, w
## Key files
-| File | Purpose |
-| ------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
-| `experiment_query_builder.py` | `get_funnel_metric_events_query_for_precomputation()` (write), precomputed CTE in `_build_funnel_query_legacy()` (read) |
-| `experiment_query_runner.py` | `_ensure_metric_events_precomputed()`, wiring in `_get_experiment_query()` |
-| `lazy_computation_executor.py` | Core lazy computation: `ensure_precomputed()`, job management |
-| `experiment_metric_events_sql.py` | ClickHouse table definition |
-| `experiment_metric_events_preaggregated.py` | HogQL schema for the table |
+| File | Purpose |
+| ------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
+| `experiment_funnel_query_builder.py` | `get_funnel_metric_events_query_for_precomputation()` (write), precomputed CTE in `build_funnel_query_legacy()` (read) |
+| `experiment_query_runner.py` | `_ensure_metric_events_precomputed()`, wiring in `_get_experiment_query()` |
+| `lazy_computation_executor.py` | Core lazy computation: `ensure_precomputed()`, job management |
+| `experiment_metric_events_sql.py` | ClickHouse table definition |
+| `experiment_metric_events_preaggregated.py` | HogQL schema for the table |
diff --git a/products/experiments/backend/hogql_queries/experiment_exposure_query_builder.py b/products/experiments/backend/hogql_queries/experiment_exposure_query_builder.py
index b92588295775..107902d150a9 100644
--- a/products/experiments/backend/hogql_queries/experiment_exposure_query_builder.py
+++ b/products/experiments/backend/hogql_queries/experiment_exposure_query_builder.py
@@ -299,13 +299,23 @@ class ExposureQueryBuilder:
return event_or_action_to_filter(self.context.team, self.context.activation_config)
return self.build_exposure_event_predicate()
- def select_query(self) -> ast.SelectQuery:
+ def reads_precomputed(self) -> bool:
+ """
+ Whether select_query() reads the precomputed exposures table. Job ids alone do not
+ decide it: activation mode and breakdowns scan events even when job ids are set.
+ """
# Activation mode never reads precomputed exposures: the per-day cache is built from
# the flag predicate alone and cannot express the cross-day flag→activation ordering.
+ if self.context.activation_config is not None:
+ return False
+ return bool(self.preaggregation_job_ids) and not self.context.breakdowns
+
+ def select_query(self) -> ast.SelectQuery:
if self.context.activation_config is not None:
return self._build_activation_exposure_select_query()
- if self.preaggregation_job_ids and not self.context.breakdowns:
+ if self.reads_precomputed():
+ assert self.preaggregation_job_ids is not None
return self.precomputed_select_query(self.preaggregation_job_ids)
return self._build_exposure_select_query()
diff --git a/products/experiments/backend/hogql_queries/experiment_funnel_query_builder.py b/products/experiments/backend/hogql_queries/experiment_funnel_query_builder.py
index 1348c74c6f0a..338b2b32e168 100644
--- a/products/experiments/backend/hogql_queries/experiment_funnel_query_builder.py
+++ b/products/experiments/backend/hogql_queries/experiment_funnel_query_builder.py
@@ -13,6 +13,7 @@ from products.experiments.backend.hogql_queries.base_query_utils import (
funnel_evaluation_expr,
funnel_steps_to_filter,
)
+from products.experiments.backend.hogql_queries.experiment_exposure_query_builder import ExposureQueryBuilder
from products.experiments.backend.hogql_queries.experiment_query_context import MaturityGate
from products.experiments.backend.hogql_queries.funnel_step_builder import FunnelStepBuilder
from products.experiments.backend.hogql_queries.funnel_validation import FunnelDWValidator
@@ -41,9 +42,18 @@ class FunnelQueryBuilder:
reads that shared state and those helpers through it.
"""
- def __init__(self, builder: "ExperimentQueryBuilder", maturity: MaturityGate | None = None):
+ def __init__(
+ self,
+ builder: "ExperimentQueryBuilder",
+ exposure: ExposureQueryBuilder,
+ *,
+ maturity: MaturityGate | None = None,
+ metric_events_job_ids: list[str] | None = None,
+ ):
self._b = builder
+ self._exposure = exposure
self._maturity = maturity
+ self._metric_events_job_ids = metric_events_job_ids
def build_funnel_query(self) -> ast.SelectQuery:
if self.should_use_optimized_funnel_query():
@@ -52,8 +62,10 @@ class FunnelQueryBuilder:
def should_use_optimized_funnel_query(self) -> bool:
# With precomputed exposures, the exposures CTE of the legacy path reads from a
- # cheap preaggregated table, so its second scan costs little.
- if self._b.preaggregation_job_ids and not self._b.breakdowns:
+ # cheap preaggregated table, so its second scan costs little. The single-scan path
+ # does not read metric-events job ids, but the runner reports metric events as
+ # precomputed whenever it has them, so the two disagree without exposure job ids.
+ if self._exposure.reads_precomputed():
return False
# Only the legacy path implements the UNION ALL pattern for DW funnels.
if isinstance(self._b.metric, ExperimentFunnelMetric) and self.has_datawarehouse_steps():
@@ -88,7 +100,7 @@ class FunnelQueryBuilder:
# array, so the step column injection below is skipped for them.
inject_step_columns = True
- if self._b.metric_events_preaggregation_job_ids and not has_dw_steps:
+ if self._metric_events_job_ids and not has_dw_steps:
inject_step_columns = False
step_extracts = ", ".join(f"arrayElement(t.steps, {i + 1}) AS step_{i}" for i in range(num_steps))
entity_id_cast = "toUUID(t.entity_id)" if self._b.entity_key == "person_id" else "t.entity_id"
@@ -184,7 +196,7 @@ class FunnelQueryBuilder:
)
"""
- exposure_query = self._b._get_exposure_query(self._maturity)
+ exposure_query = self._exposure.select_query()
if has_dw_steps:
# FunnelDWValidator guarantees that all DW steps use the same events_join_key
first_dw_step = next(s for s in self._b.metric.series if isinstance(s, ExperimentDataWarehouseNode))
@@ -214,8 +226,8 @@ class FunnelQueryBuilder:
"date_from": self._b.date_range_query.date_from_as_hogql(),
"date_to": self._b.date_range_query.date_to_as_hogql(),
}
- if self._b.metric_events_preaggregation_job_ids:
- placeholders["metric_events_job_ids"] = ast.Constant(value=self._b.metric_events_preaggregation_job_ids)
+ if self._metric_events_job_ids:
+ placeholders["metric_events_job_ids"] = ast.Constant(value=self._metric_events_job_ids)
placeholders["metric_events_team_id"] = ast.Constant(value=self._b.team.id)
placeholders["metric_events_date_from"] = self._b.date_range_query.date_from_as_hogql()
placeholders["metric_events_date_to"] = self._b.date_range_query.date_to_as_hogql()
diff --git a/products/experiments/backend/hogql_queries/experiment_mean_query_builder.py b/products/experiments/backend/hogql_queries/experiment_mean_query_builder.py
index 8b7f5d7919df..e2a5233a02df 100644
--- a/products/experiments/backend/hogql_queries/experiment_mean_query_builder.py
+++ b/products/experiments/backend/hogql_queries/experiment_mean_query_builder.py
@@ -16,7 +16,7 @@ from products.experiments.backend.hogql_queries.base_query_utils import (
is_session_property_metric,
validate_session_property,
)
-from products.experiments.backend.hogql_queries.experiment_query_context import MaturityGate
+from products.experiments.backend.hogql_queries.experiment_exposure_query_builder import ExposureQueryBuilder
from products.experiments.backend.hogql_queries.metric_source import MetricSourceInfo
if TYPE_CHECKING:
@@ -33,9 +33,16 @@ class MeanQueryBuilder:
and the shared exposure, metric-value, and CUPED helpers through it.
"""
- def __init__(self, builder: "ExperimentQueryBuilder", maturity: MaturityGate | None = None):
+ def __init__(
+ self,
+ builder: "ExperimentQueryBuilder",
+ exposure: ExposureQueryBuilder,
+ *,
+ metric_events_job_ids: list[str] | None = None,
+ ):
self._b = builder
- self._maturity = maturity
+ self._exposure = exposure
+ self._metric_events_job_ids = metric_events_job_ids
def get_session_property_ctes(self) -> str:
"""
@@ -123,7 +130,7 @@ class MeanQueryBuilder:
entity_metric_selects = """
{value_agg} AS value"""
- if self._b.metric_events_preaggregation_job_ids:
+ if self._metric_events_job_ids:
# Read from the precomputed table instead of scanning events. Only reachable
# for eligible metrics (no breakdowns/CUPED/DW/session properties), so the
# branches above never coexist with this one.
@@ -208,7 +215,7 @@ class MeanQueryBuilder:
source_info = MetricSourceInfo.from_source(self._b.metric.source, entity_key=self._b.entity_key)
- exposure_query = self._b._get_exposure_query(self._maturity)
+ exposure_query = self._exposure.select_query()
if source_info.kind == "datawarehouse":
assert isinstance(self._b.metric.source, ExperimentDataWarehouseNode)
events_join_key_parts = cast(list[str | int], self._b.metric.source.events_join_key.split("."))
@@ -254,8 +261,8 @@ class MeanQueryBuilder:
value_expr=self._b._build_windowed_metric_value_expr(cuped_pre_window_predicate)
)
- if self._b.metric_events_preaggregation_job_ids:
- placeholders["metric_events_job_ids"] = ast.Constant(value=self._b.metric_events_preaggregation_job_ids)
+ if self._metric_events_job_ids:
+ placeholders["metric_events_job_ids"] = ast.Constant(value=self._metric_events_job_ids)
placeholders["metric_events_team_id"] = ast.Constant(value=self._b.team.id)
placeholders["metric_events_date_from"] = self._b.date_range_query.date_from_as_hogql()
placeholders["metric_events_date_to"] = self._b.date_range_query.date_to_as_hogql()
@@ -274,7 +281,7 @@ class MeanQueryBuilder:
"""Placeholders for the CTEs from get_session_property_ctes()."""
assert isinstance(self._b.metric, ExperimentMeanMetric)
- exposure_query = self._b._get_exposure_query(self._maturity)
+ exposure_query = self._exposure.select_query()
return {
"exposure_select_query": exposure_query,
diff --git a/products/experiments/backend/hogql_queries/experiment_query_builder.py b/products/experiments/backend/hogql_queries/experiment_query_builder.py
index 18b424a2783b..ba926e10742b 100644
--- a/products/experiments/backend/hogql_queries/experiment_query_builder.py
+++ b/products/experiments/backend/hogql_queries/experiment_query_builder.py
@@ -149,8 +149,6 @@ class ExperimentQueryBuilder:
self.multiple_variant_handling = multiple_variant_handling
self.breakdowns = breakdowns or []
self.breakdown_injector = BreakdownInjector(self.breakdowns, metric) if metric else None
- self.preaggregation_job_ids: list[str] | None = None
- self.metric_events_preaggregation_job_ids: list[str] | None = None
self.cuped_config = cuped_config or CupedQueryConfig()
# ponytail: funnel CUPED sources its pre-exposure covariate from the metric_events
# scan, but activation mode forces the temporal filter that removes those rows, so
@@ -187,26 +185,28 @@ class ExperimentQueryBuilder:
"""
``precomputation_context`` carries the precomputed job IDs. They arrive here
and not in __init__, because the same builder generates the precompute
- queries before any job IDs exist. The IDs are stored on self so the
- metric builders read them like any other builder state.
+ queries before any job IDs exist. They go only to the builders of this build.
"""
- if precomputation_context is not None:
- self.preaggregation_job_ids = precomputation_context.exposure_job_ids
- self.metric_events_preaggregation_job_ids = precomputation_context.metric_events_job_ids
-
+ job_ids = precomputation_context or ExperimentPrecomputationContext()
# The only clock read of a build, so every maturity filter in the query uses the same cutoff.
maturity = MaturityGate.of(self.context, computed_at=timezone.now())
+ exposure = self._exposure_query_builder(maturity=maturity, job_ids=job_ids.exposure_job_ids)
+ metric_events_job_ids = job_ids.metric_events_job_ids
assert self.metric is not None, "metric is required for build_query()"
match self.metric:
case ExperimentFunnelMetric():
- query = self._build_funnel_query(maturity)
+ query = FunnelQueryBuilder(
+ self, exposure, maturity=maturity, metric_events_job_ids=metric_events_job_ids
+ ).build_funnel_query()
case ExperimentMeanMetric():
- query = self._build_mean_query(maturity)
+ query = MeanQueryBuilder(self, exposure, metric_events_job_ids=metric_events_job_ids).build_mean_query()
case ExperimentRatioMetric():
- query = self._build_ratio_query(maturity)
+ query = RatioQueryBuilder(self, exposure).build_ratio_query()
case ExperimentRetentionMetric():
- query = self._build_retention_query(maturity)
+ query = RetentionQueryBuilder(
+ self, exposure, maturity=maturity, metric_events_job_ids=metric_events_job_ids
+ ).build_retention_query()
case _:
raise NotImplementedError(
f"Only funnel, mean, ratio, and retention metrics are supported. Got {type(self.metric)}"
@@ -215,30 +215,33 @@ class ExperimentQueryBuilder:
query.limit = ast.Constant(value=self.QUERY_RESULT_LIMIT)
return query
- def _exposure_query_builder(self, maturity: MaturityGate | None = None) -> ExposureQueryBuilder:
+ def _exposure_query_builder(
+ self, maturity: MaturityGate | None = None, job_ids: list[str] | None = None
+ ) -> ExposureQueryBuilder:
"""
- Built per call so it picks up the ``preaggregation_job_ids`` that build_query() sets.
- Only the exposure select of build_query() passes ``maturity``.
+ Only build_query() passes the per-build ``maturity`` gate and exposure ``job_ids``.
+ The other callers get neither: the precompute queries, the exposure timeseries,
+ the shared predicates and the actors query.
"""
return ExposureQueryBuilder(
context=self.context,
breakdown_injector=self.breakdown_injector,
maturity=maturity,
maturity_window_seconds=self._get_maturity_window_seconds(),
- preaggregation_job_ids=self.preaggregation_job_ids,
+ preaggregation_job_ids=job_ids,
)
- def _funnel_query_builder(self, maturity: MaturityGate | None = None) -> FunnelQueryBuilder:
- return FunnelQueryBuilder(self, maturity=maturity)
-
- def _retention_query_builder(self, maturity: MaturityGate | None = None) -> RetentionQueryBuilder:
- return RetentionQueryBuilder(self, maturity=maturity)
+ def _funnel_query_builder(self) -> FunnelQueryBuilder:
+ """For the precompute write query and the actors query, which take no per-build inputs."""
+ return FunnelQueryBuilder(self, self._exposure_query_builder())
- def _mean_query_builder(self, maturity: MaturityGate | None = None) -> MeanQueryBuilder:
- return MeanQueryBuilder(self, maturity=maturity)
+ def _retention_query_builder(self) -> RetentionQueryBuilder:
+ """For the precompute write query and its scan extension, which take no per-build inputs."""
+ return RetentionQueryBuilder(self, self._exposure_query_builder())
- def _ratio_query_builder(self, maturity: MaturityGate | None = None) -> RatioQueryBuilder:
- return RatioQueryBuilder(self, maturity=maturity)
+ def _mean_query_builder(self) -> MeanQueryBuilder:
+ """For the precompute write query, which takes no per-build inputs."""
+ return MeanQueryBuilder(self, self._exposure_query_builder())
def _cuped_query_builder(self) -> CupedQueryBuilder:
return CupedQueryBuilder(self)
@@ -277,15 +280,6 @@ class ExperimentQueryBuilder:
return 0
return self._get_conversion_window_seconds()
- def _build_funnel_query(self, maturity: MaturityGate) -> ast.SelectQuery:
- return self._funnel_query_builder(maturity).build_funnel_query()
-
- def _build_mean_query(self, maturity: MaturityGate) -> ast.SelectQuery:
- return self._mean_query_builder(maturity).build_mean_query()
-
- def _build_ratio_query(self, maturity: MaturityGate) -> ast.SelectQuery:
- return self._ratio_query_builder(maturity).build_ratio_query()
-
def _build_conversion_window_predicate(self) -> ast.Expr:
"""Uses "metric_events" as the events alias."""
return build_conversion_window_predicate(self._get_conversion_window_seconds())
@@ -400,9 +394,6 @@ class ExperimentQueryBuilder:
"""
return self._exposure_query_builder().build_exposure_step_predicate()
- def _get_exposure_query(self, maturity: MaturityGate | None = None) -> ast.SelectQuery:
- return self._exposure_query_builder(maturity).select_query()
-
def get_exposure_query_for_precomputation(self) -> tuple[str, dict[str, ast.Expr]]:
"""
The query string uses {time_window_min} and {time_window_max} placeholders
@@ -441,6 +432,3 @@ class ExperimentQueryBuilder:
if isinstance(self.metric, ExperimentRetentionMetric):
return self._retention_query_builder().get_metric_events_window_extension_seconds()
return self._get_conversion_window_seconds()
-
- def _build_retention_query(self, maturity: MaturityGate) -> ast.SelectQuery:
- return self._retention_query_builder(maturity).build_retention_query()
diff --git a/products/experiments/backend/hogql_queries/experiment_ratio_query_builder.py b/products/experiments/backend/hogql_queries/experiment_ratio_query_builder.py
index 12c32fc065a9..0f381783c175 100644
--- a/products/experiments/backend/hogql_queries/experiment_ratio_query_builder.py
+++ b/products/experiments/backend/hogql_queries/experiment_ratio_query_builder.py
@@ -5,7 +5,7 @@ from posthog.schema import ExperimentDataWarehouseNode, ExperimentMetricOutlierH
from posthog.hogql import ast
from posthog.hogql.parser import parse_expr, parse_select
-from products.experiments.backend.hogql_queries.experiment_query_context import MaturityGate
+from products.experiments.backend.hogql_queries.experiment_exposure_query_builder import ExposureQueryBuilder
from products.experiments.backend.hogql_queries.metric_source import MetricSourceInfo
if TYPE_CHECKING:
@@ -21,9 +21,9 @@ class RatioQueryBuilder:
exposure and metric-value helpers through it.
"""
- def __init__(self, builder: "ExperimentQueryBuilder", maturity: MaturityGate | None = None):
+ def __init__(self, builder: "ExperimentQueryBuilder", exposure: ExposureQueryBuilder):
self._b = builder
- self._maturity = maturity
+ self._exposure = exposure
def build_ratio_query(self) -> ast.SelectQuery:
assert isinstance(self._b.metric, ExperimentRatioMetric)
@@ -220,7 +220,7 @@ class RatioQueryBuilder:
denom_entity_field = denom_source_info.entity_key
denom_timestamp_field = denom_source_info.timestamp_field
- exposure_query = self._b._get_exposure_query(self._maturity)
+ exposure_query = self._exposure.select_query()
if num_source_info.kind == "datawarehouse" or denom_source_info.kind == "datawarehouse":
# argMin takes each join key from the first exposure, so each entity_id gets one
# identifier per component. Do not add the join keys to GROUP BY: a user with
diff --git a/products/experiments/backend/hogql_queries/experiment_retention_query_builder.py b/products/experiments/backend/hogql_queries/experiment_retention_query_builder.py
index cc2bf5471ca0..f4ba11db4d81 100644
--- a/products/experiments/backend/hogql_queries/experiment_retention_query_builder.py
+++ b/products/experiments/backend/hogql_queries/experiment_retention_query_builder.py
@@ -20,6 +20,7 @@ from products.experiments.backend.hogql_queries.base_query_utils import (
data_warehouse_node_to_filter,
event_or_action_to_filter,
)
+from products.experiments.backend.hogql_queries.experiment_exposure_query_builder import ExposureQueryBuilder
from products.experiments.backend.hogql_queries.experiment_query_context import MaturityGate
if TYPE_CHECKING:
@@ -37,9 +38,18 @@ class RetentionQueryBuilder:
through it.
"""
- def __init__(self, builder: "ExperimentQueryBuilder", maturity: MaturityGate | None = None):
+ def __init__(
+ self,
+ builder: "ExperimentQueryBuilder",
+ exposure: ExposureQueryBuilder,
+ *,
+ maturity: MaturityGate | None = None,
+ metric_events_job_ids: list[str] | None = None,
+ ):
self._b = builder
+ self._exposure = exposure
self._maturity = maturity
+ self._metric_events_job_ids = metric_events_job_ids
def get_retention_maturity_seconds(self) -> int:
"""
@@ -187,7 +197,7 @@ class RetentionQueryBuilder:
"""
assert isinstance(self._b.metric, ExperimentRetentionMetric)
- if self._b.metric_events_preaggregation_job_ids:
+ if self._metric_events_job_ids:
# Read start/completion events from the precomputed table instead of scanning
# events; the event predicates were applied at build time and survive as the
# steps flags (steps[1] = matched start_event, steps[2] = matched completion_event).
@@ -302,7 +312,7 @@ class RetentionQueryBuilder:
)
placeholders = {
- "exposure_select_query": self._b._get_exposure_query(self._maturity),
+ "exposure_select_query": self._exposure.select_query(),
"entity_key": parse_expr(self._b.entity_key),
"completion_event_predicate": self.build_completion_event_predicate(),
"retention_window_start_interval": self.build_retention_window_interval(
@@ -326,8 +336,8 @@ class RetentionQueryBuilder:
placeholders["start_event_predicate"] = self.build_start_event_predicate()
placeholders["start_after_exposure_predicate"] = self.build_start_after_exposure_predicate()
- if self._b.metric_events_preaggregation_job_ids:
- placeholders["metric_events_job_ids"] = ast.Constant(value=self._b.metric_events_preaggregation_job_ids)
+ if self._metric_events_job_ids:
+ placeholders["metric_events_job_ids"] = ast.Constant(value=self._metric_events_job_ids)
placeholders["metric_events_team_id"] = ast.Constant(value=self._b.team.id)
placeholders["metric_events_date_from"] = self._b.date_range_query.date_from_as_hogql()
placeholders["metric_events_date_to"] = self._b.date_range_query.date_to_as_hogql()