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.35k stars 1.13k forks source link

fix: return query column aliases #23343

Open daibhin opened 4 days ago

daibhin commented 4 days ago

Problem

Helps to cleanup a lot in https://github.com/PostHog/posthog/pull/23330

For a query like this:

source: {
  kind: NodeKind.EventsQuery,
  select: [
    'any(properties) as "columns.context.error"',
    'properties.$exception_type',
    `sparkline(reverse(arrayMap(x -> countEqual(groupArray(dateDiff('hour', now() - INTERVAL 1 day, timestamp)), x), range(24)))) as volume`,
    'count() as unique_occurrences -- Occurrences',
    'count(distinct $session_id) as unique_sessions -- Sessions',
    'count(distinct distinct_id) as unique_users -- Users',
    'max(timestamp) as last_seen',
    'min(timestamp) as first_seen',
    ],
  orderBy: [order],
  ...defaultProperties({ dateRange, filterTestAccounts, filterGroup }),
},

the column aliases were not being returned

Changes

Before After
Screenshot 2024-06-28 at 21 03 30 Screenshot 2024-06-28 at 21 02 31