Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: hogql cohort queries #27377

Open
wants to merge 449 commits into
base: aspicer/stickiness
Choose a base branch
from
Open

Conversation

aspicer
Copy link
Contributor

@aspicer aspicer commented Jan 9, 2025

Problem

Cohorts are still calculated using old style queries.

Changes

This code doesn't change how anything is calculated.

It adds code that runs cohort queries with new hogql queries. The new hogql queries use our existing insights as a base and compute the cohorts off of clickhouse set calculations based on those.

When we recompute a cohort, we now increment the version by 2. We run the old style cohort and insert it at x+2. We then run the new hogql style cohort and insert it at version x+1, with sign set to -1 for any old queries that still rely on sign (our deprecated way of doing versioning before argmaxing).

It runs the new code after the old code so it shouldn't interfere with cohort recalculation, and logs how long they take to run, as well as any errors that crop up.

After deploy, after a day, we will be able to find all cohorts that are failing or returning different results, and then work to debug those until the new hogql cohort calculations are good enough to become primary.

Does this work well for both Cloud and self-hosted?

Yes

How did you test this code?

Wrote a test harness and updated existing cohort tests to also run the new code and make sure that the results are the same.

adamleithp and others added 25 commits January 16, 2025 12:02
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
)

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

2 snapshot changes in total. 0 added, 2 modified, 0 deleted:

  • chromium: 0 added, 2 modified, 0 deleted (wasn't pushed!)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.