Skip to content

Commit

Permalink
overrides table only in overrides mode
Browse files Browse the repository at this point in the history
  • Loading branch information
mariusandra committed Nov 23, 2023
1 parent cb47675 commit fff3448
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 79 deletions.
42 changes: 0 additions & 42 deletions posthog/hogql/database/test/__snapshots__/test_database.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -45,27 +45,6 @@
"person"
]
},
{
"key": "override",
"type": "lazy_table",
"table": "person_overrides",
"fields": [
"team_id",
"old_person_id",
"override_person_id",
"oldest_event",
"merged_at",
"created_at"
]
},
{
"key": "override_person_id",
"type": "field_traverser",
"chain": [
"override",
"override_person_id"
]
},
{
"key": "poe",
"type": "virtual_table",
Expand Down Expand Up @@ -840,27 +819,6 @@
"person"
]
},
{
"key": "override",
"type": "lazy_table",
"table": "person_overrides",
"fields": [
"team_id",
"old_person_id",
"override_person_id",
"oldest_event",
"merged_at",
"created_at"
]
},
{
"key": "override_person_id",
"type": "field_traverser",
"chain": [
"override",
"override_person_id"
]
},
{
"key": "poe",
"type": "virtual_table",
Expand Down
34 changes: 0 additions & 34 deletions posthog/hogql/test/__snapshots__/test_resolver.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@
group_2: {},
group_3: {},
group_4: {},
override: {},
override_person_id: {},
pdi: {},
person: {},
person_id: {},
Expand Down Expand Up @@ -589,8 +587,6 @@
group_2: {},
group_3: {},
group_4: {},
override: {},
override_person_id: {},
pdi: {},
person: {},
person_id: {},
Expand Down Expand Up @@ -1101,8 +1097,6 @@
group_2: {},
group_3: {},
group_4: {},
override: {},
override_person_id: {},
pdi: {},
person: {},
person_id: {},
Expand Down Expand Up @@ -1640,8 +1634,6 @@
group_2: {},
group_3: {},
group_4: {},
override: {},
override_person_id: {},
pdi: {},
person: {},
person_id: {},
Expand Down Expand Up @@ -1939,8 +1931,6 @@
group_2: {},
group_3: {},
group_4: {},
override: {},
override_person_id: {},
pdi: {},
person: {},
person_id: {},
Expand Down Expand Up @@ -2240,8 +2230,6 @@
group_2: {},
group_3: {},
group_4: {},
override: {},
override_person_id: {},
pdi: {},
person: {},
person_id: {},
Expand Down Expand Up @@ -2498,8 +2486,6 @@
group_2: {},
group_3: {},
group_4: {},
override: {},
override_person_id: {},
pdi: {},
person: {},
person_id: {},
Expand Down Expand Up @@ -2630,8 +2616,6 @@
group_2: {},
group_3: {},
group_4: {},
override: {},
override_person_id: {},
pdi: {},
person: {},
person_id: {},
Expand Down Expand Up @@ -2766,8 +2750,6 @@
group_2: {},
group_3: {},
group_4: {},
override: {},
override_person_id: {},
pdi: {},
person: {},
person_id: {},
Expand Down Expand Up @@ -2938,8 +2920,6 @@
group_2: {},
group_3: {},
group_4: {},
override: {},
override_person_id: {},
pdi: {},
person: {},
person_id: {},
Expand Down Expand Up @@ -3115,8 +3095,6 @@
group_2: {},
group_3: {},
group_4: {},
override: {},
override_person_id: {},
pdi: {},
person: {},
person_id: {},
Expand Down Expand Up @@ -3250,8 +3228,6 @@
group_2: {},
group_3: {},
group_4: {},
override: {},
override_person_id: {},
pdi: {},
person: {},
person_id: {},
Expand Down Expand Up @@ -3386,8 +3362,6 @@
group_2: {},
group_3: {},
group_4: {},
override: {},
override_person_id: {},
pdi: {},
person: {},
person_id: {},
Expand Down Expand Up @@ -3503,8 +3477,6 @@
group_2: {},
group_3: {},
group_4: {},
override: {},
override_person_id: {},
pdi: {},
person: {},
person_id: {},
Expand Down Expand Up @@ -3713,8 +3685,6 @@
group_2: {},
group_3: {},
group_4: {},
override: {},
override_person_id: {},
pdi: {},
person: {},
person_id: {},
Expand Down Expand Up @@ -3808,8 +3778,6 @@
group_2: {},
group_3: {},
group_4: {},
override: {},
override_person_id: {},
pdi: {},
person: {},
person_id: {},
Expand Down Expand Up @@ -3915,8 +3883,6 @@
group_2: {},
group_3: {},
group_4: {},
override: {},
override_person_id: {},
pdi: {},
person: {},
person_id: {},
Expand Down
6 changes: 3 additions & 3 deletions posthog/hogql/test/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ def test_prop_cohort_static(self):
cohort = Cohort.objects.create(team=self.team, groups=[], is_static=True)
cohort.insert_users_by_list(["some_id"])

with override_settings(PERSON_ON_EVENTS_V2_OVERRIDE=False):
with override_settings(PERSON_ON_EVENTS_OVERRIDE=False, PERSON_ON_EVENTS_V2_OVERRIDE=False):
response = execute_hogql_query(
"SELECT event, count() FROM events WHERE {cohort_filter} GROUP BY event",
team=self.team,
Expand All @@ -539,7 +539,7 @@ def test_prop_cohort_static(self):
f"SELECT events.event, count() FROM events INNER JOIN (SELECT argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id, person_distinct_id2.distinct_id AS distinct_id FROM person_distinct_id2 WHERE equals(person_distinct_id2.team_id, {self.team.pk}) GROUP BY person_distinct_id2.distinct_id HAVING ifNull(equals(argMax(person_distinct_id2.is_deleted, person_distinct_id2.version), 0), 0)) AS events__pdi ON equals(events.distinct_id, events__pdi.distinct_id) WHERE and(equals(events.team_id, {self.team.pk}), ifNull(in(events__pdi.person_id, (SELECT person_static_cohort.person_id FROM person_static_cohort WHERE and(equals(person_static_cohort.team_id, {self.team.pk}), equals(person_static_cohort.cohort_id, {cohort.pk})))), 0)) GROUP BY events.event LIMIT 100 SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1",
)

with override_settings(PERSON_ON_EVENTS_V2_OVERRIDE=True):
with override_settings(PERSON_ON_EVENTS_OVERRIDE=True, PERSON_ON_EVENTS_V2_OVERRIDE=False):
response = execute_hogql_query(
"SELECT event, count(*) FROM events WHERE {cohort_filter} GROUP BY event",
team=self.team,
Expand All @@ -550,11 +550,11 @@ def test_prop_cohort_static(self):
)
},
)
self.assertEqual(response.results, [("$pageview", 1)])
self.assertEqual(
response.clickhouse,
f"SELECT events.event, count(*) FROM events WHERE and(equals(events.team_id, {self.team.pk}), in(events.person_id, (SELECT person_static_cohort.person_id FROM person_static_cohort WHERE and(equals(person_static_cohort.team_id, {self.team.pk}), equals(person_static_cohort.cohort_id, {cohort.pk}))))) GROUP BY events.event LIMIT 100 SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1",
)
self.assertEqual(response.results, [("$pageview", 1)])

def test_join_with_property_materialized_session_id(self):
with freeze_time("2020-01-10"):
Expand Down

0 comments on commit fff3448

Please sign in to comment.