From 529c540b5752bedc4a8869926d418b07f93b1d56 Mon Sep 17 00:00:00 2001 From: Marius Andra Date: Thu, 25 Jan 2024 15:25:04 +0100 Subject: [PATCH] adjustments --- posthog/hogql/query.py | 6 ++++-- posthog/hogql/test/test_modifiers.py | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/posthog/hogql/query.py b/posthog/hogql/query.py index 5bbd0d98c6324..42ba19eaa9618 100644 --- a/posthog/hogql/query.py +++ b/posthog/hogql/query.py @@ -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] @@ -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() diff --git a/posthog/hogql/test/test_modifiers.py b/posthog/hogql/test/test_modifiers.py index fc31cfe99eea8..7c5d1722b3a7a 100644 --- a/posthog/hogql/test/test_modifiers.py +++ b/posthog/hogql/test/test_modifiers.py @@ -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 @@ -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 @@ -176,6 +178,7 @@ 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 @@ -183,6 +186,7 @@ def test_modifiers_materialization_mode(self): "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"