diff --git a/posthog/hogql/database/schema/test/test_cohort_people.py b/posthog/hogql/database/schema/test/test_cohort_people.py new file mode 100644 index 0000000000000..4dce61f10c6f0 --- /dev/null +++ b/posthog/hogql/database/schema/test/test_cohort_people.py @@ -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"