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 bf795f9515e955c770af12f8734700607a902a13 Author: KSPT-taylorjohn <[email protected]> AuthorDate: Thu Aug 31 18:05:39 2023 -0400 fix: Chart series limit doesn't work for some databases (#25150) --- superset/models/helpers.py | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/superset/models/helpers.py b/superset/models/helpers.py index 59db27d404..8e9e8e4302 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"] @@ -1391,7 +1392,19 @@ class ExploreMixin: # pylint: disable=too-many-public-methods } columns = columns or [] groupby = groupby or [] +<<<<<<< HEAD series_column_names = utils.get_column_names(series_columns or []) +======= + rejected_adhoc_filters_columns: list[Union[str, ColumnTyping]] = [] + applied_adhoc_filters_columns: list[Union[str, ColumnTyping]] = [] + 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 [], + ) + ] +>>>>>>> bbfaeb074... fix: Chart series limit doesn't work for some databases (#25150) # deprecated, to be removed in 2.0 if is_timeseries and timeseries_limit: series_limit = timeseries_limit @@ -1404,8 +1417,12 @@ 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) +<<<<<<< HEAD db_engine_spec = self.db_engine_spec prequeries: List[str] = [] +======= + prequeries: list[str] = [] +>>>>>>> bbfaeb074... fix: Chart series limit doesn't work for some databases (#25150) orderby = orderby or [] need_groupby = bool(metrics is not None or groupby) metrics = metrics or [] @@ -1545,8 +1562,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: @@ -1926,7 +1943,24 @@ 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)) +<<<<<<< HEAD tbl = tbl.join(subq.alias(), and_(*on_clause)) +======= + tbl = tbl.join(subq.alias(SERIES_LIMIT_SUBQ_ALIAS), and_(*on_clause)) + else: + if series_limit_metric: + orderby = [ + ( + self._get_series_orderby( + series_limit_metric=series_limit_metric, + metrics_by_name=metrics_by_name, + columns_by_name=columns_by_name, + template_processor=template_processor, + ), + not order_desc, + ) + ] +>>>>>>> bbfaeb074... fix: Chart series limit doesn't work for some databases (#25150) # run prequery to get top groups prequery_obj = {
