Skip to content

Commit

Permalink
Fix web analytics tests
Browse files Browse the repository at this point in the history
  • Loading branch information
robbie-c committed Mar 21, 2024
1 parent ab64f8a commit 260f0ed
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 4 additions & 0 deletions posthog/hogql/ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,15 @@ def resolve_constant_type(self, context: HogQLContext):
def resolve_database_field(self, context: HogQLContext):
if isinstance(self.type, FieldType):
return self.type.resolve_database_field(context)
if isinstance(self.type, PropertyType):
return self.type.field_type.resolve_database_field(context)
raise NotImplementedException("FieldAliasType.resolve_database_field not implemented")

def resolve_table_type(self, context: HogQLContext):
if isinstance(self.type, FieldType):
return self.type.table_type
if isinstance(self.type, PropertyType):
return self.type.field_type.table_type
raise NotImplementedException("FieldAliasType.resolve_table_type not implemented")


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,9 +350,11 @@ def visit_alias(self, node: ast.Alias) -> bool:

if node.type and isinstance(node.type, ast.FieldAliasType):
resolved_field = node.type.resolve_database_field(self.context)
table = node.type.resolve_table_type(self.context).table
return (isinstance(table, EventsTable) and resolved_field.name == "timestamp") or (
isinstance(table, SessionsTable) and resolved_field.name == "min_timestamp"
table_type = node.type.resolve_table_type(self.context)
if not table_type or not isinstance(table_type, ast.TableType):
return False
return (isinstance(table_type.table, EventsTable) and resolved_field.name == "timestamp") or (
isinstance(table_type.table, SessionsTable) and resolved_field.name == "min_timestamp"
)

return self.visit(node.expr)
Expand Down

0 comments on commit 260f0ed

Please sign in to comment.