Skip to content

Commit

Permalink
fix typing
Browse files Browse the repository at this point in the history
  • Loading branch information
timgl committed Oct 25, 2024
1 parent 7b08365 commit 156b875
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion posthog/hogql/database/schema/persons.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ def select_from_persons_table(
# For now, only do this optimization for directly querying the persons table (without joins or as part of a subquery) to avoid knock-on effects to insight queries
if (
node.select_from
and getattr(node.select_from.type, "table", False)
and node.select_from.type
and hasattr(node.select_from.type, "table")
and node.select_from.type.table
and isinstance(node.select_from.type.table, PersonsTable)
):
extractor = WhereClauseExtractor(context)
Expand Down
3 changes: 3 additions & 0 deletions posthog/hogql/database/schema/test/test_persons.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ def test_simple_filter(self):
modifiers=self.modifiers,
)
assert len(response.results) == 2
assert response.clickhouse
self.assertIn("where_optimization", response.clickhouse)
self.assertNotIn("in(tuple(person.id, person.version)", response.clickhouse)

Expand All @@ -94,6 +95,7 @@ def test_joins_are_left_alone_for_now(self):
modifiers=self.modifiers,
)
assert len(response.results) == 2
assert response.clickhouse
self.assertIn("in(tuple(person.id, person.version)", response.clickhouse)
self.assertNotIn("where_optimization", response.clickhouse)

Expand Down Expand Up @@ -122,4 +124,5 @@ def test_person_modal_not_optimized_yet(self):
)
query_runner = ActorsQueryRunner(query=actors_query, team=self.team)
response = execute_hogql_query(query_runner.to_query(), self.team, modifiers=self.modifiers)
assert response.clickhouse
self.assertNotIn("where_optimization", response.clickhouse)

0 comments on commit 156b875

Please sign in to comment.