Skip to content

Commit

Permalink
Fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Gilbert09 committed Mar 19, 2024
1 parent dfc55c2 commit cf63938
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion posthog/hogql/database/test/test_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def test_database_expression_fields(self):
query = print_ast(parse_select(sql), context, dialect="clickhouse")
assert (
query
== "SELECT number AS number FROM (SELECT numbers.number AS number FROM numbers(2) AS numbers) LIMIT 10000"
== "SELECT number AS number, expression AS expression, double AS double FROM (SELECT numbers.number AS number, plus(1, 1) AS expression, multiply(numbers.number, 2) AS double FROM numbers(2) AS numbers) LIMIT 10000"
), query

def test_database_warehouse_joins(self):
Expand Down
3 changes: 3 additions & 0 deletions posthog/hogql/visitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,9 @@ def visit_window_frame_expr(self, node: ast.WindowFrameExpr):
def visit_join_constraint(self, node: ast.JoinConstraint):
self.visit(node.expr)

def visit_expression_field_type(self, node: ast.ExpressionFieldType):
self.visit(node.expr)

def visit_hogqlx_tag(self, node: ast.HogQLXTag):
for attribute in node.attributes:
self.visit(attribute)
Expand Down
5 changes: 4 additions & 1 deletion posthog/warehouse/models/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,10 @@ class TableFormat(models.TextChoices):
__repr__ = sane_repr("name")

def table_name_without_prefix(self) -> str:
prefix = self.external_data_source.prefix
if self.external_data_source is not None and self.external_data_source.prefix is not None:
prefix = self.external_data_source.prefix
else:
prefix = ""
return self.name[len(prefix) :]

def get_columns(self, safe_expose_ch_error=True) -> Dict[str, str]:
Expand Down

0 comments on commit cf63938

Please sign in to comment.