From ac75ac56aef05660c16fa2bf76f79460034b315c Mon Sep 17 00:00:00 2001 From: eric Date: Fri, 15 Mar 2024 14:46:00 -0600 Subject: [PATCH] returning --- .../insights/trends/trends_query_runner.py | 36 +++++++++++++------ 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/posthog/hogql_queries/insights/trends/trends_query_runner.py b/posthog/hogql_queries/insights/trends/trends_query_runner.py index 6cf84dcb5357b..0ba3519a023e4 100644 --- a/posthog/hogql_queries/insights/trends/trends_query_runner.py +++ b/posthog/hogql_queries/insights/trends/trends_query_runner.py @@ -61,6 +61,7 @@ HogQLQueryModifiers, DataWarehouseEventsModifier, ) +from posthog.warehouse.models import DataWarehouseTable from posthog.utils import format_label_date @@ -696,18 +697,33 @@ def _is_breakdown_field_boolean(self): ): return False - if self.query.breakdownFilter.breakdown_type == "person": - property_type = PropertyDefinition.Type.PERSON - elif self.query.breakdownFilter.breakdown_type == "group": - property_type = PropertyDefinition.Type.GROUP + if self.query.breakdownFilter.breakdown_type == "data_warehouse": + series = self.query.series[0] # only one series when data warehouse is active + table_model = ( + DataWarehouseTable.objects.filter(name=series.table_name, team=self.team).exclude(deleted=True).first() + ) + + field_type = table_model.columns[self.query.breakdownFilter.breakdown] + + if field_type.startswith("Nullable("): + field_type = field_type.replace("Nullable(", "")[:-1] + + if field_type == "Bool": + return True + else: - property_type = PropertyDefinition.Type.EVENT + if self.query.breakdownFilter.breakdown_type == "person": + property_type = PropertyDefinition.Type.PERSON + elif self.query.breakdownFilter.breakdown_type == "group": + property_type = PropertyDefinition.Type.GROUP + else: + property_type = PropertyDefinition.Type.EVENT - field_type = self._event_property( - self.query.breakdownFilter.breakdown, - property_type, - self.query.breakdownFilter.breakdown_group_type_index, - ) + field_type = self._event_property( + self.query.breakdownFilter.breakdown, + property_type, + self.query.breakdownFilter.breakdown_group_type_index, + ) return field_type == "Boolean" def _convert_boolean(self, value: Any):