From 8786c878ebceaeac715c28c4b7b1b152a1e767a8 Mon Sep 17 00:00:00 2001 From: Daniel Bachhuber Date: Wed, 11 Dec 2024 10:46:05 -0800 Subject: [PATCH] fix(experiments): Add a WHERE statement to ASOF LEFT JOIN (#26848) --- posthog/warehouse/models/join.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/posthog/warehouse/models/join.py b/posthog/warehouse/models/join.py index b24d6916e93c9..3eda8275c0337 100644 --- a/posthog/warehouse/models/join.py +++ b/posthog/warehouse/models/join.py @@ -128,6 +128,11 @@ def _join_function_for_experiments( }.items() ], select_from=ast.JoinExpr(table=ast.Field(chain=["events"])), + where=ast.CompareOperation( + op=ast.CompareOperationOp.Eq, + left=ast.Field(chain=["event"]), + right=ast.Constant(value="$feature_flag_called"), + ), ), # ASOF JOIN finds the most recent matching event that occurred at or before each data warehouse timestamp. #