-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
fix(experiments): fix old aggregation_group_type_index being copied to the new query #20889
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, the problem with this fix is that it breaks what
updateQuerySource
is supposed to do: i.e only do additive updates. I'm not 100% sure where the fix should go, but definitely sure this isn't the right way.Consider how there's no problem with this in regular insights, this just introduces an exception that shouldn't be there. For example, now, whenever we call updateQuerySource without the
aggregation_group_type_index
, it resets it to persons aggregation, which is not ok.The problem here that needs to be fixed is in our code: Our
querySource
never returns anundefined
foraggregation_group_type_index
, and instead omits it, because there are several 'gates' it needs to pass through:cleanFilters
returns the undefined value (I think this wasn't reverted from the previous PR - we stopped passing in the aggregation group type index here)filtersToQueryNode
also returns the group_type_index, which is currently removed when undefined.Now, it doesn't make sense for me to update
filtersToQueryNode
- it's doing the right thing it's supposed to do, discard every random empty thing and create a clean Query node. Our problem is that experiments want to use the output of this for additive updates, where the group type index being undefined needs to pass through.Thus, I suggest creating a helper function for experiments that:
filtersToQueryNode
and adds props we definitely want to be sent alongside. This isolates the change to our experiments code.filtersToQueryNode
so it returns all undefined things as well.Currently prefer (1), but
filtersToQueryNode
seem to be majorly used by experiments only. @thmsobrmlr since you wrote this, any ideas / is there a different filter to query function we should be using for updates? (or @mariusandra )The problematic bits in question start here: https://github.com/PostHog/posthog/blob/master/frontend/src/scenes/experiments/experimentLogic.tsx#L386
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without looking deeper (1) sounds like a good suggestion. I'll try to have a look at this later as well.
No, there is only the
filtersToQueryNode
function.Also note that we're actively working on removing all filters and the
filtersToQueryNode
andcleanFilters
functions with it. If you're doing a bigger refactoring, transitioning all the way to queries is the way to go.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, not using
filters
, butquery
directly is the way to go. All insights usequery
natively for example, and we're deprecating this old style.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm on the backend we're still storing filters for experiments, so not yet ready to completely get rid of them, but I'm guessing what you're suggesting is that while we're in client-side land, all interactions ought to happen using the
query
, and then at the end when saving we can convert it into a filter so the backend can continue using it to calculate metrics?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah exactly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All HogQL insights use "query" in the backend natively, and once we're done with the refactor and ready to drop legacy insights, the "filters" object will no longer be used anywhere... except for the experiments backend then 😄.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Experiments backend passes on the filter to Trends / Funnel query runner, we don't do any manual custom queries, so I guess once we're ready to drop legacy insights we should easily migrate too :D - let me know when you're about ready, I'm assuming you'll have some way to convert saved insight filters to query, we'll need a similar mechanism for experiments.
(Juraj - your call to make for the frontend query changes, my suggestion would be to do this Query migration right after we've done the UI revamp (vs. now), unless in the middle of the revamp you feel things become much easier to do the query migration as well)