Skip to content

Commit

Permalink
fix: Allow clickhouse dbs with timestamps to visualize queries (apach…
Browse files Browse the repository at this point in the history
…e#21446)

(cherry picked from commit 4d0c2ba)
  • Loading branch information
hughhhh authored and sadpandajoe committed Oct 3, 2022
1 parent 2c45290 commit 22fac9e
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 22fac9e

Please sign in to comment.