order_by_cols is a raw-mode-only control (resetOnHide: false), so an
aggregate chart can carry a stale value. The form-data query-context
rebuild read it in every mode, which could order an aggregate export by
stale columns and return a different top-N than the chart shows. Gate it
behind is_raw_query_mode so aggregate mode falls back to the metric-based
ordering, mirroring the frontend Table buildQuery.
Also add frontend-drift pointers naming the mirrored buildQuery /
extractQueryFields / processFilters sources, and a regression test for an
aggregate table with a stale order_by_cols.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Further review of the form-data query-context rebuild:
- Raw-mode tables: ignore stale metrics/groupby (their controls aren't
reset when hidden) and use only the selected columns, mirroring the
frontend's getQueryMode (explicit query_mode, else all_columns).
- Ordering: default order_desc to False (ascending) for Table sort
metrics and True for Pie, matching the plugins — so a row limit keeps
the chart's top/bottom-N instead of flipping it.
- percent_metrics: skip the chart (re-save) rather than silently omitting
the "% of total" columns the user sees, alongside the other
unsupported-processing markers.
Adds regression tests for each; extracts a helper to keep the builder
under the complexity limit.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Address further review of the form-data query-context rebuild:
- Skip the rebuild when the form data relies on processing the single
query can't reproduce: time_compare, rolling_type, resample_rule, or
aggregation=raw. Even allowlisted viz types would otherwise export
values that differ from the chart.
- Big Number trendline: set granularity (so time_grain_sqla buckets the
promoted time column) even with no active time_range.
- Export applies only WHERE-clause SIMPLE filters (via a new where_only
arg), matching the chart, while the shared helper still converts all
SIMPLE filters for the MCP path.
Adds regression tests for each case.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- Exclude percent_metrics from the rebuild: the chart shows them as a
"% of total" via contribution post-processing the rebuild can't apply,
so adding them as plain metrics would export raw aggregates that don't
match the chart.
- Restore converting all SIMPLE adhoc filters (not just WHERE-clause) so
SIMPLE HAVING filters the MCP compile/preview path relied on are not
silently dropped.
- Fall back to legacy since/until when time_range is absent, so older
charts export their configured range instead of the full history.
- Add an MCP-path test pinning that an explicitly empty `columns: []` no
longer shadows `groupby` (intentional behavior change), plus tests for
the since/until fallback and SIMPLE HAVING conversion.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>