posthog icon indicating copy to clipboard operation
posthog copied to clipboard

feat(data-exploration): pivot tables

Open mariusandra opened this issue 3 years ago • 3 comments

Changes

Very much a MVP, with likely a ridiculously unoptimised query, but we can pivot now!

2022-12-09 01 52 24

How did you test this code?

Got it working this far, then clicked around in joy.

mariusandra avatar Dec 09 '22 00:12 mariusandra

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week.

posthog-bot avatar Dec 26 '22 07:12 posthog-bot

This PR was closed due to lack of activity. Feel free to reopen if it's still relevant.

posthog-bot avatar Jan 02 '23 07:01 posthog-bot

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week.

posthog-bot avatar Jan 10 '23 07:01 posthog-bot

This PR was closed due to lack of activity. Feel free to reopen if it's still relevant.

posthog-bot avatar Jan 18 '23 07:01 posthog-bot

Probably going to re-implement... but still keeping this open :)

mariusandra avatar Jan 18 '23 21:01 mariusandra

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week.

posthog-bot avatar Jan 26 '23 07:01 posthog-bot

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week.

posthog-bot avatar Feb 03 '23 07:02 posthog-bot

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week.

posthog-bot avatar Feb 13 '23 07:02 posthog-bot

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week.

posthog-bot avatar Feb 21 '23 07:02 posthog-bot

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week.

posthog-bot avatar Mar 01 '23 07:03 posthog-bot

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week.

posthog-bot avatar Mar 09 '23 07:03 posthog-bot

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week.

posthog-bot avatar Mar 17 '23 07:03 posthog-bot

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week.

posthog-bot avatar Mar 27 '23 07:03 posthog-bot

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week.

posthog-bot avatar Apr 04 '23 07:04 posthog-bot

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week.

posthog-bot avatar Apr 13 '23 07:04 posthog-bot

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week.

posthog-bot avatar Apr 25 '23 07:04 posthog-bot

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week.

posthog-bot avatar May 03 '23 07:05 posthog-bot

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week.

posthog-bot avatar May 11 '23 07:05 posthog-bot

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week.

posthog-bot avatar May 19 '23 07:05 posthog-bot

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week.

posthog-bot avatar May 29 '23 07:05 posthog-bot

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week.

posthog-bot avatar Jun 06 '23 07:06 posthog-bot

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week.

posthog-bot avatar Jun 14 '23 07:06 posthog-bot

This PR has gotten so stale it's not worth merging it in. We'll reimplement this, now that HogQL is out.

For anyone landing here via Google, this query is how you'd get something like a pivot table in HogQL:

 WITH PIVOT_TABLE_COL_ABC AS (
       SELECT properties.index as col_a,
              event as col_b,
              count() as col_c
         FROM events
     GROUP BY properties.index,
              event
    ),
    PIVOT_FUNCTION_1 AS (
        select col_a, groupArray( (col_b, col_c) ) as g from
          PIVOT_TABLE_COL_ABC
          group by col_a
    ),
    PIVOT_FUNCTION_2 AS (
        select col_a, arrayZip( (sumMap( g.1, g.2 ) as x).1, x.2) r from
        PIVOT_FUNCTION_1
        group by col_a
    )
   SELECT *
     FROM PIVOT_FUNCTION_2
 ORDER BY col_a

mariusandra avatar Jun 15 '23 12:06 mariusandra