Skip to content

Commit

Permalink
Update models.py
Browse files Browse the repository at this point in the history
  • Loading branch information
xingyc15 committed Oct 28, 2021
1 parent f838d2b commit f0aec1a
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions superset/connectors/sqla/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,10 @@ def get_time_filter(
return and_(*l)

def get_timestamp_expression(
self, time_grain: Optional[str], label: Optional[str] = None,
template_processor: Optional[BaseTemplateProcessor] = None
self,
time_grain: Optional[str],
label: Optional[str] = None,
template_processor: Optional[BaseTemplateProcessor] = None,
) -> Union[TimestampExpression, Label]:
"""
Return a SQLAlchemy Core element representation of self to be used in a query.
Expand Down Expand Up @@ -1096,7 +1098,8 @@ def get_sqla_query( # pylint: disable=too-many-arguments,too-many-locals,too-ma
outer = table_col.get_timestamp_expression(
time_grain=time_grain,
label=selected,
template_processor=template_processor)
template_processor=template_processor,
)
# if groupby field equals a selected column
elif table_col:
outer = table_col.get_sqla_col()
Expand Down Expand Up @@ -1130,8 +1133,8 @@ def get_sqla_query( # pylint: disable=too-many-arguments,too-many-locals,too-ma

if is_timeseries:
timestamp = dttm_col.get_timestamp_expression(
time_grain=time_grain,
template_processor=template_processor)
time_grain=time_grain, template_processor=template_processor
)
# always put timestamp as the first column
select_exprs.insert(0, timestamp)
groupby_all_columns[timestamp.name] = timestamp
Expand Down Expand Up @@ -1197,8 +1200,8 @@ def get_sqla_query( # pylint: disable=too-many-arguments,too-many-locals,too-ma
if col_obj:
if filter_grain:
sqla_col = col_obj.get_timestamp_expression(
time_grain=filter_grain,
template_processor=template_processor)
time_grain=filter_grain, template_processor=template_processor
)
else:
sqla_col = col_obj.get_sqla_col()
col_spec = db_engine_spec.get_column_spec(col_obj.type)
Expand Down

0 comments on commit f0aec1a

Please sign in to comment.