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): in cohort joins with version as well #21552

Merged
merged 4 commits into from
Apr 16, 2024
Merged

Conversation

mariusandra
Copy link
Collaborator

@mariusandra mariusandra commented Apr 15, 2024

Problem

The PR #21543 added an optimization for cohort queries: using a numeric version directly, instead of grouping by the maximum.

Seems like the join option for the "in cohort via" HogQL modifier needed to be modified as well.

Changes

Makes the "in cohort via" option "join" also use a faster query.

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

Yup

How did you test this code?

This isn't used anywhere, but neither is it tested 🤔

Copy link
Contributor

github-actions bot commented Apr 16, 2024

Size Change: -2 B (0%)

Total Size: 999 kB

ℹ️ View Unchanged
Filename Size Change
frontend/dist/toolbar.js 999 kB -2 B (0%)

compressed-size-action

@mariusandra mariusandra marked this pull request as ready for review April 16, 2024 08:41
@mariusandra mariusandra requested a review from a team April 16, 2024 08:42
@@ -354,6 +357,8 @@ def _add_join_for_cohort(
if must_add_join:
if is_static:
sql = "(SELECT person_id, 1 as matched FROM static_cohort_people WHERE cohort_id = {cohort_id})"
elif version is not None:
sql = "(SELECT person_id, 1 as matched FROM raw_cohort_people WHERE cohort_id = {cohort_id} AND version = {version})"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is version value supplied for the placeholder?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you raise a very good question

@mariusandra mariusandra merged commit 99de66f into master Apr 16, 2024
98 checks passed
@mariusandra mariusandra deleted the in-cohort-join branch April 16, 2024 15:51
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.

2 participants