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): run filter based insights via hogql #17611

Merged
merged 6 commits into from
Sep 27, 2023

Conversation

thmsobrmlr
Copy link
Contributor

@thmsobrmlr thmsobrmlr commented Sep 25, 2023

Problem

We're still using the legacy insight query when fetching results from the insights api.

Changes

This PR

  • adds a feature flag HOGQL_INSIGHTS_OVERRIDE with implementation similar to the PoE one
  • hooks into the insight_result serializer method to use an alternative path for insights that support it, when the flag is on
  • the alternative path converts the filters to a query, and then uses the query runner to compute the output / return the cached response

How did you test this code?

Added a test and verified manually for the lifecycle query. There are still some rough edges e.g. the demo test account filter doesn't work as the validation breaks for cohort filters.

Don't forget to set "HOGQL_INSIGHTS_OVERRIDE": "True"

Base automatically changed from filter-to-query-node to master September 26, 2023 06:24
@thmsobrmlr thmsobrmlr force-pushed the insight-via-hogql-from-filter branch from 40709da to 258b88a Compare September 26, 2023 06:25
@PostHog PostHog deleted a comment from posthog-bot Sep 26, 2023
@thmsobrmlr thmsobrmlr marked this pull request as ready for review September 26, 2023 13:29
@thmsobrmlr thmsobrmlr requested a review from a team September 26, 2023 13:29
Copy link
Collaborator

@mariusandra mariusandra left a comment

Choose a reason for hiding this comment

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

I didn't run, but looks good overall.
Will this force us to enable/disable hogql insights per team? We might want to still run them per user, as they're even too raw for usage within the company?

@thmsobrmlr
Copy link
Contributor Author

I didn't run, but looks good overall.

👍

Will this force us to enable/disable hogql insights per team? We might want to still run them per user, as they're even too raw for usage within the company?

I think so, yes. Will look into adding a user based version as well.

@thmsobrmlr
Copy link
Contributor Author

Turns out we can only base the feature flags on users OR teams, not both. Thus changed the logic to rely on users for now. We can git revert b4d5f25f22018e348b98ec53cfe3ed1dfeb9477d later on.

@thmsobrmlr thmsobrmlr enabled auto-merge (squash) September 27, 2023 07:53
@thmsobrmlr thmsobrmlr merged commit cb22ba7 into master Sep 27, 2023
@thmsobrmlr thmsobrmlr deleted the insight-via-hogql-from-filter branch September 27, 2023 08:14
@sentry-io
Copy link

sentry-io bot commented Sep 27, 2023

Suspect Issues

This pull request was deployed and Sentry observed the following issues:

  • ‼️ AttributeError: 'AnonymousUser' object has no attribute 'distinct_id' /shared/{access_token} View Issue

Did you find this useful? React with a 👍 or 👎

thmsobrmlr added a commit that referenced this pull request Sep 27, 2023
thmsobrmlr added a commit that referenced this pull request Sep 27, 2023
…17641)

Revert "feat(hogql): run filter based insights via hogql (#17611)"

This reverts commit cb22ba7.
thmsobrmlr added a commit that referenced this pull request Sep 27, 2023
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