Skip to content

Commit

Permalink
fix: Allow clickhouse dbs with timestamps to visualize queries (#21446)
Browse files Browse the repository at this point in the history
  • Loading branch information
hughhhh committed Oct 3, 2022
1 parent 4245bc3 commit 4d0c2ba
Showing 1 changed file with 23 additions and 18 deletions.
41 changes: 23 additions & 18 deletions superset/models/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1570,26 +1570,31 @@ def get_sqla_query( # pylint: disable=too-many-arguments,too-many-locals,too-ma
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))
Expand Down

0 comments on commit 4d0c2ba

Please sign in to comment.