Skip to content

Commit

Permalink
adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
mariusandra committed Jan 25, 2024
1 parent fdc4f10 commit 529c540
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 4 additions & 2 deletions posthog/hogql/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ def execute_hogql_query(
)

with timings.measure("print_ast"):
hogql = print_prepared_ast(select_query_hogql, hogql_query_context, "hogql", pretty=pretty)
hogql = print_prepared_ast(
select_query_hogql, hogql_query_context, "hogql", pretty=pretty if pretty is not None else True
)
print_columns = []
columns_query = (
select_query_hogql.select_queries[0]
Expand Down Expand Up @@ -134,7 +136,7 @@ def execute_hogql_query(
context=clickhouse_context,
dialect="clickhouse",
settings=settings,
pretty=pretty,
pretty=pretty if pretty is not None else True,
)

timings_dict = timings.to_dict()
Expand Down
4 changes: 4 additions & 0 deletions posthog/hogql/test/test_modifiers.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ def test_modifiers_materialization_mode(self):
"SELECT properties.$browser FROM events",
team=self.team,
modifiers=HogQLQueryModifiers(materializationMode=MaterializationMode.auto),
pretty=False,
)
assert (
"SELECT nullIf(nullIf(events.`mat_$browser`, ''), 'null') AS `$browser` FROM events" in response.clickhouse
Expand All @@ -167,6 +168,7 @@ def test_modifiers_materialization_mode(self):
"SELECT properties.$browser FROM events",
team=self.team,
modifiers=HogQLQueryModifiers(materializationMode=MaterializationMode.legacy_null_as_null),
pretty=False,
)
assert (
"SELECT nullIf(nullIf(events.`mat_$browser`, ''), 'null') AS `$browser` FROM events" in response.clickhouse
Expand All @@ -176,13 +178,15 @@ def test_modifiers_materialization_mode(self):
"SELECT properties.$browser FROM events",
team=self.team,
modifiers=HogQLQueryModifiers(materializationMode=MaterializationMode.legacy_null_as_string),
pretty=False,
)
assert "SELECT nullIf(events.`mat_$browser`, '') AS `$browser` FROM events" in response.clickhouse

response = execute_hogql_query(
"SELECT properties.$browser FROM events",
team=self.team,
modifiers=HogQLQueryModifiers(materializationMode=MaterializationMode.disabled),
pretty=False,
)
assert (
"SELECT replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, %(hogql_val_0)s), ''), 'null'), '^\"|\"$', '') AS `$browser` FROM events"
Expand Down

0 comments on commit 529c540

Please sign in to comment.