Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: series limit solution for source is query #20977

Merged
merged 5 commits into from
Aug 4, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
49 changes: 35 additions & 14 deletions superset/models/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -888,14 +888,26 @@ def _normalize_prequery_result_type(
column_ = columns_by_name[dimension]
db_extra: Dict[str, Any] = self.database.get_extra() # type: ignore

if column_.type and column_.is_temporal and isinstance(value, str):
sql = self.db_engine_spec.convert_dttm(
column_.type, dateutil.parser.parse(value), db_extra=db_extra
)
if isinstance(column_, dict):
if (
column_.get("type")
and column_.get("is_temporal")
and isinstance(value, str)
):
sql = self.db_engine_spec.convert_dttm(
column_.get("type"), dateutil.parser.parse(value), db_extra=None
)

if sql:
value = self.text(sql)
if sql:
value = self.db_engine_spec.get_text_clause(sql)
else:
if column_.type and column_.is_temporal and isinstance(value, str):
sql = self.db_engine_spec.convert_dttm(
column_.type, dateutil.parser.parse(value), db_extra=db_extra
)

if sql:
value = self.text(sql)
return value

def make_orderby_compatible(
Expand Down Expand Up @@ -1827,12 +1839,22 @@ def get_sqla_query( # pylint: disable=too-many-arguments,too-many-locals,too-ma
inner_time_filter = []

if dttm_col and not db_engine_spec.time_groupby_inline:
inner_time_filter = [
dttm_col.get_time_filter(
inner_from_dttm or from_dttm,
inner_to_dttm or to_dttm,
)
]
if isinstance(dttm_col, dict):
inner_time_filter = [
self.get_time_filter(
dttm_col,
inner_from_dttm or from_dttm,
inner_to_dttm or to_dttm,
)
]
else:
inner_time_filter = [
dttm_col.get_time_filter(
inner_from_dttm or from_dttm,
inner_to_dttm or to_dttm,
)
]

subq = subq.where(and_(*(where_clause_and + inner_time_filter)))
subq = subq.group_by(*inner_groupby_exprs)

Expand Down Expand Up @@ -1866,8 +1888,7 @@ def get_sqla_query( # pylint: disable=too-many-arguments,too-many-locals,too-ma
"columns": columns,
"order_desc": True,
}

result = self.query(prequery_obj) # type: ignore
result = self.exc_query(prequery_obj)
prequeries.append(result.query)
dimensions = [
c
Expand Down