fix(insights): coerce nullable string args of array-returning functions#58704
fix(insights): coerce nullable string args of array-returning functions#58704sampennington wants to merge 1 commit into
Conversation
splitByChar (and the other string-splitting functions) return Array(...).
Given a Nullable string argument — e.g. a breakdown on splitByChar('@',
properties.$distinct_id) — ClickHouse would produce Nullable(Array(...)),
which it rejects, failing the whole insight query.
The printer now wraps a nullable string argument of these functions in
ifNull(arg, '') so the result type stays a plain Array.
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 SummaryThe fix is correct and minimal: array-returning string functions with a Function-list completeness (main concern)The new
Minor
Test
VerdictNeeds changes — ship-quality fix, but add the missing |
Problem
An insight using
splitByChar(or another string-splitting function) on a nullable value crashed the whole query with ClickHouseNested type Array(String) cannot be inside Nullable type. Surfaced fromsystem.query_log(exception_code = 43) as part of the effort to reduce deterministic query-builder bugs (dashboard).splitByCharand friends returnArray(...). A JSON property resolves to aNullable(String), so e.g. a breakdown onsplitByChar('@', properties.$distinct_id)producesNullable(Array(String))— a type ClickHouse forbids.Changes
splitByChar,splitByString,splitByRegexp,splitByWhitespace,splitByNonAlpha,alphaTokens,extractAllGroups,ngrams,tokens) inifNull(arg, ''), keeping the result a plainArray.How did you test this code?
I'm an agent. Automated tests run locally:
test_split_function_on_nullable_propertyexecutingsplitByChar('@', properties.email).posthog/hogql/printer/test/test_printer.pysuite — 608 passed, 175 snapshots unchanged.Publish to changelog?
no
🤖 Agent context
Authored by Claude Code (Opus 4.7). Found via
system.query_loganalysis (exception_code = 43,Nested type Array(...) cannot be inside Nullable).Only nullable string args are wrapped (checked via the resolved arg type), so non-nullable args and non-string args like the split-count are untouched — no snapshot churn for existing split-function usage.
Agent-authored; requires human review.