This is an automated email from the ASF dual-hosted git repository. hugh pushed a commit to branch 2022.39.1 in repository https://gitbox.apache.org/repos/asf/superset.git
commit 22fac9e7e6bbeff08a35ed370b30cae57be6916d Author: Hugh A. Miles II <[email protected]> AuthorDate: Mon Oct 3 14:22:20 2022 -0400 fix: Allow clickhouse dbs with timestamps to visualize queries (#21446) (cherry picked from commit 4d0c2ba6ef3f8ca7479cf46383ddac9470aa3329) --- superset/models/helpers.py | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/superset/models/helpers.py b/superset/models/helpers.py index c81d268a1e..da526b559c 100644 --- a/superset/models/helpers.py +++ b/superset/models/helpers.py @@ -1570,26 +1570,31 @@ class ExploreMixin: # pylint: disable=too-many-public-methods groupby_all_columns[timestamp.name] = timestamp # Use main dttm column to support index with secondary dttm columns. - if ( - db_engine_spec.time_secondary_columns - and self.main_dttm_col in self.dttm_cols - and self.main_dttm_col != dttm_col.column_name - ): - if isinstance(self.main_dttm_col, dict): - time_filters.append( - self.get_time_filter( - self.main_dttm_col, - from_dttm, - to_dttm, - ) - ) + if db_engine_spec.time_secondary_columns: + if isinstance(dttm_col, dict): + dttm_col_name = dttm_col.get("column_name") else: - time_filters.append( - columns_by_name[self.main_dttm_col].get_time_filter( - from_dttm, - to_dttm, + dttm_col_name = dttm_col.column_name + + if ( + self.main_dttm_col in self.dttm_cols + and self.main_dttm_col != dttm_col_name + ): + if isinstance(self.main_dttm_col, dict): + time_filters.append( + self.get_time_filter( + self.main_dttm_col, + from_dttm, + to_dttm, + ) + ) + else: + time_filters.append( + columns_by_name[self.main_dttm_col].get_time_filter( + from_dttm, + to_dttm, + ) ) - ) if isinstance(dttm_col, dict): time_filters.append(self.get_time_filter(dttm_col, from_dttm, to_dttm))
