fix(insights): fix funnel correlation join for HogQL aggregation#58708
fix(insights): fix funnel correlation join for HogQL aggregation#58708sampennington wants to merge 1 commit into
Conversation
A funnel correlation query joined events to the funnel actors on event.person_id. When the funnel aggregates by a custom HogQL expression, funnel_actors.actor_id holds that expression's value (e.g. a string), not a person UUID — so the join failed with TYPE_MISMATCH (no supertype for UUID and String). _get_aggregation_target_join_query now joins on the funnel's funnelAggregateByHogQL expression when one is set, matching how the funnel actors CTE computes actor_id. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
🎭 Playwright didn't run on this PR — your changes touch code that could affect E2E behavior, but Playwright is opt-in via label now to keep CI cost down. Add the Most PRs don't need this. Real regressions still get caught on master and fix-forward. |
Automated code reviewReviewed CorrectnessThe fix correctly mirrors the upstream actor expression — SQL safetyNo new injection surface — the interpolated expression lands inside the Possible concern — column resolution scopeThe join evaluates the expression against the correlation Tests
Verdict: Ship it — strengthen the test assertion (and ideally add a
|
Problem
A funnel correlation query crashed with ClickHouse
TYPE_MISMATCH(no supertype for types UUID, String) when the funnel aggregated by a custom HogQL expression. Surfaced fromsystem.query_log(exception_code = 53) as part of the effort to reduce deterministic query-builder bugs (dashboard)._get_aggregation_target_join_queryonly handled two cases — person aggregation (event.person_id) and group aggregation (event.$group_N). With a custom HogQL aggregation (funnelAggregateByHogQL), it fell back to the person join, comparingevent.person_id(UUID) againstfunnel_actors.actor_id(the HogQL expression's value, e.g. a string).Changes
_get_aggregation_target_join_querynow joins on the funnel'sfunnelAggregateByHogQLexpression when one is set, matching how the funnel actors CTE computesactor_id.How did you test this code?
I'm an agent. Automated tests run locally:
test_funnel_correlation_with_events_and_hogql_aggregation— a correlation query over a funnel aggregating byproperties.session_id. Verified it fails (TYPE_MISMATCH) without the fix and passes with it.test_funnel_correlation.pysuite — 19 passed.Publish to changelog?
no
🤖 Agent context
Authored by Claude Code (Opus 4.7). Found via
system.query_loganalysis (exception_code = 53,Can't infer common type for joined columns).Scope note: the sibling
_get_aggregation_join_query(person/group properties correlation) has the same person/group-only assumption, but property correlation against a non-person aggregation target is a different code path and wasn't in the observed failures — left for a separate change if it surfaces.Agent-authored; requires human review.