-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8148b11
commit f1a2f78
Showing
1 changed file
with
44 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
from posthog.hogql.parser import parse_select | ||
from posthog.hogql.query import execute_hogql_query | ||
from posthog.models import Person, Cohort | ||
from posthog.test.base import ( | ||
APIBaseTest, | ||
ClickhouseTestMixin, | ||
) | ||
|
||
|
||
class TestCohortPeopleTable(ClickhouseTestMixin, APIBaseTest): | ||
def test_select_star(self): | ||
Person.objects.create( | ||
team_id=self.team.pk, | ||
distinct_ids=["1"], | ||
properties={"$some_prop": "something", "$another_prop": "something1"}, | ||
) | ||
Person.objects.create( | ||
team_id=self.team.pk, | ||
distinct_ids=["2"], | ||
properties={"$some_prop": "something", "$another_prop": "something2"}, | ||
) | ||
cohort1 = Cohort.objects.create( | ||
team=self.team, | ||
groups=[ | ||
{ | ||
"properties": [ | ||
{"key": "$some_prop", "value": "something", "type": "person"}, | ||
] | ||
} | ||
], | ||
name="cohort1", | ||
) | ||
cohort1.calculate_people_ch(pending_version=0) | ||
|
||
response = execute_hogql_query( | ||
parse_select( | ||
"select *, person.properties.$another_prop from cohort_people order by person.properties.$another_prop" | ||
), | ||
self.team, | ||
) | ||
assert response.columns == ["person_id", "cohort_id", "$another_prop"] | ||
assert len(response.results) == 2 | ||
assert response.results[0][2] == "something1" | ||
assert response.results[1][2] == "something2" |