-
Notifications
You must be signed in to change notification settings - Fork 1.9k
feat(data-exploration): HogQL filters again #13830
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
Merged
Merged
Conversation
This file contains hidden or 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
…o hogql-small-refactor
… hogql-filters-again
… hogql-filters-again
mariusandra
commented
Jan 31, 2023
ee/clickhouse/queries/funnels/test/__snapshots__/test_funnel.ambr
Outdated
Show resolved
Hide resolved
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
It would be great to use HogQL in property filters.
This is a lighter version of #13264 . Probably makes a lot of old tickets obsolete.
Changes
Adds support for HogQL filters in a lot of places. Everything is behind the
hogql_expressions
feature flag.HogQL support in insights, including access to event and person properties:
HogQL support elsewhere:
Technical changes:
hogql_context
object deeply into queries.values: Dict[str, Any]
, which collects encountered string literals in HogQLvalues
is justhogql_context.values[f"val_{val.length}"] = 'string'
, so the keys are rather predictable.hogql_context.values
need to be passed onto the SQL query, and hence get passed around a lot viahogql_context=filter.hogql_context
or equivalent code. That's where a lot of the changes come in.HogQLContext
to aFilter
, to make it easier to pass the context around queries. Note that callingfilter.with_data
(cloning a filter) passes the context by reference, meaning both the old and new filter will gather variables into the same dict.get_entity_cohort_subquery
that I just couldn't find used anywhere@override_settings(PERSON_ON_EVENTS_OVERRIDE=False) # :KLUDGE: avoid making a bunch of extra queries that may be cached instance-wide
. Forcing this setting avoids all manner of SQL queries (up to 5 per test) that run whenis_cloud()
,posthoganalytics.feature_enabled()
andactor_on_events_ready()
(checks async migrations) functions are called. Since we're going to "solve" the person on events issue soon, and I couldn't work out a reliable pattern between how to mock all of this with all the tests that run in CI, I decided to patch 5 test files and tell them to consider person on events disabled. For now.How did you test this code?
Work in progress