fix(insights): coerce funnel aggregation target before empty check#58713
fix(insights): coerce funnel aggregation target before empty check#58713sampennington wants to merge 2 commits into
Conversation
The funnel event query filters out rows whose HogQL aggregation key is empty with `aggregation_target != ''`. When the aggregation key is a property with a Numeric PropertyDefinition, the property-types transform coerces it to Float64, so ClickHouse tries to parse the empty-string literal as a number and fails with "Cannot read floating point value: while converting '' to Float64" (code 72). Wrap the aggregation target in toString() for the empty-string comparison so it works regardless of the resolved column type. The isNotNull check is unaffected. 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. |
Query snapshots: Backend query snapshots updatedChanges: 1 snapshots (1 modified, 0 added, 0 deleted) What this means:
Next steps:
|
Automated code reviewReviewed the diff end-to-end (core change, new test, all 5 snapshot files). Critical issuesNone. Functional gapsNone blocking.
Snapshot verificationConfirmed the Positive
Verdict: Ship itAutomated review — posted on behalf of a code-reviewer agent. |
Problem
Funnel queries that aggregate by a HogQL expression resolving to a Numeric-typed property fail deterministically with
Cannot read floating point value: while converting '' to Float64(code 72).FunnelEventQuery._aggregation_target_filterfilters out rows whose aggregation key is empty usingaggregation_target != ''. When the aggregation key is a property with a NumericPropertyDefinition, the property-types transform coerces it toFloat64, so ClickHouse tries to parse the empty-string literal as a number.Part of an effort to reduce deterministic product-analytics query-builder failures — tracking dashboard: https://metabase.prod-us.posthog.dev/dashboard/207-product-analytics-insight-query-failures
Changes
Wrap the aggregation target in
toString()for the empty-string comparison so it works regardless of the resolved column type. TheisNotNullcheck is unchanged.Updated funnel snapshots — the only diff is the mechanical
notEquals(aggregation_target, '')→notEquals(toString(aggregation_target), '')substitution (72 occurrences).How did you test this code?
I'm an agent. Added an executing funnel test (
test_hogql_aggregation_by_numeric_property) that aggregates a funnel by a Numeric property and runs against ClickHouse. Verified the test fails onorigin/masterwith the exactcode 72error and passes with the fix. Ran the funnel, strict, unordered, and correlation test suites — all pass. Snapshot diff is limited to the intended substitution.Publish to changelog?
no
🤖 Agent context
Agent-authored (Claude Code, Opus 4.7). Requires human review.
Root cause traced from a production failing query where the funnel aggregated by
properties.bidId(Numeric property). The Float64 coercion is applied by the property-types transform; the empty-string comparison is the only place that assumes a string-typed aggregation target. Snapshots were regenerated, then narrowed back to only the intended substitution (a full--snapshot-updatealso deleted unrelated stale snapshots, which were reverted to keep the PR scoped).