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

chore(hogql): Add retention queries in HogQL #18831

Merged
merged 60 commits into from
Dec 6, 2023
Merged

Conversation

webjunkie
Copy link
Contributor

@webjunkie webjunkie commented Nov 22, 2023

Problem

We want to convert the retention queries to use HogQL as well.

Changes

  • make new retention query runner

How did you test this code?

  • test in frontend using feature flag
  • copied tests from old retention query and adapted them, made all pass

@webjunkie webjunkie changed the title chore(hogql): Add retention queries as HogQL chore(hogql): Add retention queries in HogQL Nov 22, 2023
@webjunkie
Copy link
Contributor Author

@mariusandra This is a bit rough from the code maybe, but mostly working. The tests fail at some poe stuff. Let's maybe discuss that tomorrow. Otherwise: Did I miss anything big?

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.

Didn't get to the end yet, but sharing the comments I already have.

@cached_property
@property
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm, why this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It tripped up the tests. The test uses a team, asserts something, then sets the team timezone, and tries to assert once more. But due to the timezone property that the test uses being cached here on the instance, it didn't reflect the change. Not sure why it worked in the old tests.

But, I wouldn't recommend to put cached_property on "simple" properties like these anyways, since they are directly computed from available data and do not need to be queried for or such. It's often times more a source of confusion and stale data than helping performance. Hence I removed it. What do you think?

@@ -498,8 +498,13 @@ export interface FunnelsQuery extends InsightsQueryBase {

/** `RetentionFilterType` minus everything inherited from `FilterType` */
export type RetentionFilter = Omit<RetentionFilterType, keyof FilterType>

export interface RetentionQueryResponse extends QueryResponse {
results: any[]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would be great to have this a bit more complete

posthog/hogql_queries/insights/retention_query_runner.py Outdated Show resolved Hide resolved
posthog/hogql_queries/insights/retention_query_runner.py Outdated Show resolved Hide resolved
posthog/hogql_queries/insights/retention_query_runner.py Outdated Show resolved Hide resolved
posthog/hogql_queries/insights/retention_query_runner.py Outdated Show resolved Hide resolved
posthog/hogql_queries/insights/retention_query_runner.py Outdated Show resolved Hide resolved
@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

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

  • chromium: 0 added, 1 modified, 0 deleted (diff for shard 1)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

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

Triggered by this commit.

👉 Review this PR's diff of snapshots.

@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

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

  • chromium: 0 added, 3 modified, 0 deleted (diff for shard 1)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

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

  • chromium: 0 added, 3 modified, 0 deleted (diff for shard 1)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

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

  • chromium: 0 added, 1 modified, 0 deleted (diff for shard 1)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

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

  • chromium: 0 added, 1 modified, 0 deleted (diff for shard 1)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

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

  • chromium: 0 added, 1 modified, 0 deleted (diff for shard 1)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

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

  • chromium: 0 added, 1 modified, 0 deleted (diff for shard 1)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

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

  • chromium: 0 added, 1 modified, 0 deleted (diff for shard 1)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

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

  • chromium: 0 added, 1 modified, 0 deleted (diff for shard 2)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

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

Triggered by this commit.

👉 Review this PR's diff of snapshots.

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 think this looks good! Great work! 👍

Still some tests / types to fix though, and then the persons modal stuff... but otherwise, let's get it in!

}
result.retentionFilter = {} // Put this here to make TS happy
Copy link
Collaborator

Choose a reason for hiding this comment

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

It seems to make TS unhappy...
I don't understand why we need it. Shouldn't filtersToQueryNode take care of stuff like that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have the query typed to require retentionFilter, hence added it, but since it's empty the result var didn't contain it and the equal test was failing. Anyway, I just used a cast to bypass issues now.

# Conflicts:
#	frontend/__snapshots__/scenes-app-sidepanels--side-panel-settings.png
@webjunkie webjunkie enabled auto-merge (squash) December 6, 2023 16:28
@webjunkie webjunkie merged commit 65e5ba7 into master Dec 6, 2023
78 checks passed
@webjunkie webjunkie deleted the chore/hogql-retention branch December 6, 2023 16:42
@mariusandra mariusandra mentioned this pull request Dec 7, 2023
48 tasks
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.

4 participants