You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by el...@apache.org on 2023/10/20 22:54:44 UTC
[superset] 06/07: fix: Chart series limit doesn't work for some databases (#25150)
This is an automated email from the ASF dual-hosted git repository.
elizabeth pushed a commit to branch 2.1
in repository https://gitbox.apache.org/repos/asf/superset.git
commit 17f1d3587616e6cd67ca33a1e8f0d5c73fc17e89
Author: KSPT-taylorjohn <52...@users.noreply.github.com>
AuthorDate: Thu Aug 31 18:05:39 2023 -0400
fix: Chart series limit doesn't work for some databases (#25150)
---
superset/models/helpers.py | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/superset/models/helpers.py b/superset/models/helpers.py
index 4c68e807d4..795cc6faa3 100644
--- a/superset/models/helpers.py
+++ b/superset/models/helpers.py
@@ -100,6 +100,7 @@ config = app.config
logger = logging.getLogger(__name__)
VIRTUAL_TABLE_ALIAS = "virtual_table"
+SERIES_LIMIT_SUBQ_ALIAS = "series_limit"
ADVANCED_DATA_TYPES = config["ADVANCED_DATA_TYPES"]
@@ -1387,7 +1388,13 @@ class ExploreMixin: # pylint: disable=too-many-public-methods
}
columns = columns or []
groupby = groupby or []
- series_column_names = utils.get_column_names(series_columns or [])
+ db_engine_spec = self.db_engine_spec
+ series_column_labels = [
+ db_engine_spec.make_label_compatible(column)
+ for column in utils.get_column_names(
+ columns=series_columns or [],
+ )
+ ]
# deprecated, to be removed in 2.0
if is_timeseries and timeseries_limit:
series_limit = timeseries_limit
@@ -1400,8 +1407,7 @@ class ExploreMixin: # pylint: disable=too-many-public-methods
template_kwargs["removed_filters"] = removed_filters
template_kwargs["applied_filters"] = applied_template_filters
template_processor = self.get_template_processor(**template_kwargs)
- db_engine_spec = self.db_engine_spec
- prequeries: List[str] = []
+ prequeries: list[str] = []
orderby = orderby or []
need_groupby = bool(metrics is not None or groupby)
metrics = metrics or []
@@ -1541,8 +1547,8 @@ class ExploreMixin: # pylint: disable=too-many-public-methods
)
groupby_all_columns[outer.name] = outer
if (
- is_timeseries and not series_column_names
- ) or outer.name in series_column_names:
+ is_timeseries and not series_column_labels
+ ) or outer.name in series_column_labels:
groupby_series_columns[outer.name] = outer
select_exprs.append(outer)
elif columns:
@@ -1922,7 +1928,7 @@ class ExploreMixin: # pylint: disable=too-many-public-methods
col_name = db_engine_spec.make_label_compatible(gby_name + "__")
on_clause.append(gby_obj == sa.column(col_name))
- tbl = tbl.join(subq.alias(), and_(*on_clause))
+ tbl = tbl.join(subq.alias(SERIES_LIMIT_SUBQ_ALIAS), and_(*on_clause))
# run prequery to get top groups
prequery_obj = {