From b7bda7031e6067c5d093d4fceeb539feb7e35777 Mon Sep 17 00:00:00 2001 From: John Bodley <4567245+john-bodley@users.noreply.github.com> Date: Fri, 29 Oct 2021 11:57:58 -0700 Subject: [PATCH] fix: revert "feat(sqla): apply time grain to all temporal groupbys" (#17239) * Revert "feat(sqla): apply time grain to all temporal groupbys (#16318)" This reverts commit 9075e4206c95a868206cc264dad4efd6e962c1d1. * Update models.py --- superset/connectors/sqla/models.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/superset/connectors/sqla/models.py b/superset/connectors/sqla/models.py index c19f01fb2cfb1..c3d440a624f64 100644 --- a/superset/connectors/sqla/models.py +++ b/superset/connectors/sqla/models.py @@ -1092,16 +1092,16 @@ def get_sqla_query( # pylint: disable=too-many-arguments,too-many-locals,too-ma columns = groupby or columns for selected in columns: # if groupby field/expr equals granularity field/expr - table_col = columns_by_name.get(selected) - if table_col and table_col.type_generic == GenericDataType.TEMPORAL: - outer = table_col.get_timestamp_expression( + if selected == granularity: + sqla_col = columns_by_name[selected] + outer = sqla_col.get_timestamp_expression( time_grain=time_grain, label=selected, template_processor=template_processor, ) # if groupby field equals a selected column - elif table_col: - outer = table_col.get_sqla_col() + elif selected in columns_by_name: + outer = columns_by_name[selected].get_sqla_col() else: outer = literal_column(f"({selected})") outer = self.make_sqla_column_compatible(outer, selected)