posthog icon indicating copy to clipboard operation
posthog copied to clipboard

People View broken when using HogQL

Open amplitudesxd opened this issue 9 months ago • 4 comments

Bug Description

Bug description

The People View doesn't work when using a custom HogQL query. For example, with the custom breakdown query ifNull(cutToFirstSignificantSubdomain(properties.server), '') the following error appears:

image

From my testing, this happens no matter the query - as long as it's using HogQL. Meanwhile, if using a property from the "Event properties" list PostHog provides by default, the People View works as normal.

I've checked logs of the server while doing this, and no error appears.

How to reproduce

  1. Create Insight
  2. Breakdown by a custom HogQL query
  3. Click on the graph to open people view

Debug info

  • [x] PostHog Hobby self-hosted with docker compose, version/commit: 19e7d28595

amplitudesxd avatar May 07 '24 18:05 amplitudesxd

Full error text if of use:

Illegal type (Nullable(String)) of 2 argument of function and: While processing ((team_id AS team_id) = 1) AND (event = 'joined server') AND (toTimeZone(timestamp AS timestamp, 'UTC') >= toDateTime('2024-05-05 00:00:00', 'UTC')) AND (toTimeZone(timestamp, 'UTC') <= toDateTime('2024-05-05 23:59:59', 'UTC')) AND ((NOT has(['localhost'], replaceRegexpAll(JSONExtractRaw(properties, 'server'), '^"|"$', ''))) AND cutToFirstSignificantSubdomain(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(properties AS properties, 'server'), ''), 'null'), '^"|"$', ''))).

amplitudesxd avatar May 07 '24 18:05 amplitudesxd

Hey, what happens if you try the other way around, like cutToFirstSignificantSubdomain(properties.server ?? '') (you can use ?? instead of ifNull)

mariusandra avatar May 07 '24 20:05 mariusandra

@mariusandra Thank you for the suggestion. I've just tried this, but the error persists - this time with Illegal type (String) of 2 argument of function and: While processing ((team_id AS team_id) = 1) AND (event = 'joined server') AND (toTimeZone(timestamp AS timestamp, 'UTC') >= toDateTime('2024-05-07 00:00:00', 'UTC')) AND (toTimeZone(timestamp, 'UTC') <= toDateTime('2024-05-07 23:59:59', 'UTC')) AND ((NOT has(['localhost'], replaceRegexpAll(JSONExtractRaw(properties, 'server'), '^"|"$', ''))) AND cutToFirstSignificantSubdomain(ifNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(properties AS properties, 'server'), ''), 'null'), '^"|"$', ''), '')))..

Only difference seemingly being Nullable(String) changing to String. I don't believe it's related to the type, but more just using HogQL.

amplitudesxd avatar May 07 '24 20:05 amplitudesxd

Just found this related issue (#17270), seems to have been a problem for a while

amplitudesxd avatar May 12 '24 12:05 amplitudesxd