aminghadersohi commented on code in PR #43771:
URL: https://github.com/apache/superset/pull/43771#discussion_r4202060799
##########
superset/common/form_data_query_context.py:
##########
@@ -23,30 +23,188 @@
carry no ``query_context``, so server-side consumers that need to run the query
(e.g. the dashboard Excel export) have nothing to execute.
-This module rebuilds a best-effort query context from the form data — columns,
-metrics, filters (including free-form SQL and the time range), ordering and
time
-grain — mirroring the shared parts of the viz plugins' ``buildQuery``. Beyond
-that shared core it reproduces exactly one piece of plugin post-processing,
Pie's
-unconditional ``contribution`` operator (see
-:func:`_pie_contribution_post_processing`). It does **not** reproduce any other
-post-processing (pivot, percent-metric transforms, rolling/forecast) or
-multi-query fan-out, so callers must restrict it to viz types whose data maps
-faithfully to a single query.
+This module rebuilds query contexts from form data — columns, metrics, filters,
+ordering, temporal state, limits, query fan-out, and registered visualization
+post-processing — mirroring the shared frontend extractor and explicit plugin
+``buildQuery`` adapters. MCP compile, SQL, preview, and data fallback products
+consume the same QueryObject contract as the legacy common fallback.
The mirrored logic lives on the frontend in
-``superset-frontend/plugins/plugin-chart-table/src/buildQuery.ts`` (query mode,
-ordering), ``superset-frontend/packages/superset-ui-core/src/query/`` (field
-extraction, ``processFilters``). There is no automated tripwire tying the two
-across the language boundary; the per-helper pointers below must be kept in
sync
-when that frontend logic changes.
+``superset-frontend/plugins/*/buildQuery.ts`` and
+``superset-frontend/packages/superset-ui-core/src/query/`` (field extraction,
+``processFilters``). The adapter tests pin the Python QueryObject dictionaries;
+the per-helper pointers below must still be kept in sync when frontend
contracts
+change.
"""
from __future__ import annotations
+from collections.abc import Mapping
from typing import Any
from superset.utils import json
-from superset.utils.core import as_list, get_metric_name
+from superset.utils.core import as_list, DTTM_ALIAS, get_column_name,
get_metric_name
+
+# Keep this mapping identical to ``queryFieldAliases`` in
+# ``superset-ui-core/src/query/extractQueryFields.ts``. It is the shared
+# frontend contract for every form-data key that can contribute a metric,
+# column, or ordering expression to a QueryObject. Server-side consumers and
+# MCP replacement cleanup import this contract rather than maintaining partial
+# chart-specific copies.
+FORM_DATA_QUERY_FIELD_ALIASES: dict[str, str] = {
+ "metric": "metrics",
+ "metric_2": "metrics",
+ "secondary_metric": "metrics",
+ "left_metric": "metrics",
+ "right_metric": "metrics",
Review Comment:
Fixed in f2acaab6defc45cd7680662feced6b74dae95d02.
Added open, close, high, and low to the shared metric alias mapping,
matching extractQueryFields.ts. Regression:
test_candlestick_fallback_selects_all_ohlc_metrics verifies all four metrics
reach the fallback QueryObject.
Validation: 851 tests passed across the 11 touched/related pytest modules;
pre-commit passed for all changed files. The regression coverage fails against
the previous implementation and passes with this fix.
##########
superset/mcp_service/chart/chart_helpers.py:
##########
@@ -815,6 +1152,14 @@ def build_mixed_timeseries_secondary(
)
+def with_x_axis_column(form_data: dict[str, Any], groupby: list[Any]) ->
list[Any]:
Review Comment:
Fixed in f2acaab6defc45cd7680662feced6b74dae95d02.
Confirmed there were no remaining callers and removed with_x_axis_column,
build_mixed_timeseries_secondary, _DECK_TIMESERIES_VIZ_TYPES, and
_columns_and_metrics. Query construction continues through the shared adapter.
Regression: test_unused_query_builders_are_removed guards against reintroducing
the duplicate builders.
Validation: 851 tests passed across the 11 touched/related pytest modules;
pre-commit passed for all changed files. The regression coverage fails against
the previous implementation and passes with this fix.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]