PostHog / posthog

🦔 PostHog provides open-source product analytics, session recording, feature flagging and A/B testing that you can self-host.
https://posthog.com
Other
19.72k stars 1.16k forks source link

HogQL trying to use materialized column and failing in EU #20785

Open pauldambra opened 4 months ago

pauldambra commented 4 months ago

The session replay page has a version checker... it runs:

const query: HogQLQuery = {
                        kind: NodeKind.HogQLQuery,
                        query: hogql`SELECT properties.$lib_version AS lib_version, max(timestamp) AS latest_timestamp, count(lib_version) as count
                                FROM events
                                WHERE timestamp >= now() - INTERVAL 1 DAY 
                                AND timestamp <= now()
                                AND properties.$lib = 'web'
                                GROUP BY lib_version
                                ORDER BY latest_timestamp DESC
                                limit 10`,
                    }

In the EU when navigating to the page you get

Load used versions failed: There's no column 'events.mat_$lib_version' in table. Note: While in beta, not all column types may be fully supported

So, something is not right 🙈

pauldambra commented 4 months ago

cc @MarconLP

mariusandra commented 4 months ago

No matter the cloud, we fetch the materialized columns with essentially a show columns from events statement (not real code), and then only use the columns this provides.

Thus this points to a ClickHouse problem... somehow?

I [ran this](https://eu.posthog.com/project/1/debug#q=%7B%0A%20%20%22kind%22%3A%20%22HogQLQuery%22%2C%0A%20%20%22query%22%3A%20%22SELECT%20properties.%24lib_version%20AS%20lib_version%2C%20max(timestamp)%20AS%20latest_timestamp%2C%20count(lib_version)%20as%20count%5CnFROM%20events%5CnWHERE%20timestamp%20%3E%3D%20now()%20-%20INTERVAL%201%20DAY%20%5CnAND%20timestamp%20%3C%3D%20now()%5CnAND%20properties.%24lib%20%3D%20'web'%5CnGROUP%20BY%20lib_version%5CnORDER%20BY%20latest_timestamp%20DESC%5Cnlimit%2010%22%2C%0A%20%20%22explain%22%3A%20true%2C%0A%20%20%22filters%22%3A%20%7B%0A%20%20%20%20%22dateRange%22%3A%20%7B%0A%20%20%20%20%20%20%22date_from%22%3A%20%22-24h%22%0A%20%20%20%20%7D%0A%20%20%7D%0A%7D) on EU just now and it returned data, including the mat_ bit.

image