Skip to content

fix(examples): replace deprecated timeseries_limit_metric with series_limit_metric - #43422

Merged
eschutho merged 2 commits into
masterfrom
fix/birth-names-series-limit-metric
Aug 22, 2026
Merged

eschutho merged 2 commits into
masterfrom
fix/birth-names-series-limit-metric

Conversation

@eschutho

Copy link
Copy Markdown
Member

Decisions made that were not in the instructions
None.

What the warning was

Production logs showed a recurring WARNING on every request that touched the bundled birth_names example data:

The field `timeseries_limit_metric` is deprecated, please use `series_limit_metric` instead.

QueryObject._rename_deprecated_fields (superset/common/query_object.py) fires this warning whenever it sees the old field name in incoming kwargs, then silently copies the value onto series_limit_metric. The example data shipped with Superset itself was still using the old name, so every load of the example dashboard/charts triggered the warning for no reason.

What changed

  1. superset/examples/birth_names.py — renamed 4 timeseries_limit_metric= call sites to series_limit_metric= (the "Girls"/"Boys" table slices, one echarts_timeseries_line slice, and the "Names Sorted by Num in California" slice).
  2. superset/examples/usa_births_names/charts/{Boys,Girls}.yaml — same rename in the newer YAML-fixture version of the same example dashboard, which was hit by the same warning via a separate load_examples_from_configs code path.
  3. superset/common/form_data_query_context.py — orderby_from_form_data() only ever read the deprecated timeseries_limit_metric key when reconstructing a query straight from a chart's persisted params (used by dashboard Excel export and the MCP chart tools). That meant a chart saved with the current series_limit_metric field — like the examples fixed here — would silently lose its sort-by-metric through that specific path. Added a series_limit_metric-first fallback, matching the pattern already used in query_object.py and models/helpers.py.

No behavior change

series_limit_metric and timeseries_limit_metric are treated as fully equivalent everywhere in the normal query/chart-data path (QueryObject, get_sqla_query, ChartDataQueryObjectSchema) — the rename is a no-op there other than dropping the warning. Item 3 above is a genuine bug fix for the one path that previously checked only the old key, but restores intended behavior (existing sort-by-metric) rather than changing it.

Test plan

  • superset/examples/usa_births_names/charts/{Boys,Girls}.yaml — validated as parseable YAML.
  • tests/unit_tests/common/test_form_data_query_context.py — added two tests: series_limit_metric alone produces the same orderby as the deprecated field, and series_limit_metric takes precedence when both are present. Confirmed fail-before/pass-after against the pre-fix code (both new tests fail on main, pass after the form_data_query_context.py change).
  • ruff check / ruff format --check clean on all changed Python files.
  • Full targeted suite: pytest tests/unit_tests/common/test_form_data_query_context.py → 40 passed.

…es_limit_metric

birth_names.py's bundled example slices were still constructing chart
params with the deprecated timeseries_limit_metric field, which
QueryObject silently renames to series_limit_metric with a deprecation
warning on every request. Use the current field name directly - no
behavior change, since QueryObject treats the two as equivalent.
… form_data fallback

Self-review found two gaps in the birth_names.py rename:

- The newer YAML-fixture twin of the same example (usa_births_names/charts/
  Boys.yaml, Girls.yaml) still used timeseries_limit_metric, so it would
  keep firing the same deprecation warning on every load. Renamed both.

- orderby_from_form_data() in form_data_query_context.py only ever checked
  the deprecated timeseries_limit_metric key when reconstructing a query
  context straight from a chart's persisted params (used by dashboard
  Excel export and the MCP chart tools). Charts saved with the current
  series_limit_metric field name - including the just-fixed birth_names
  examples - would silently lose their sort-by-metric through this path.
  Added a series_limit_metric-first fallback, matching the pattern already
  used in query_object.py and models/helpers.py.
@dosubot dosubot Bot added the doc:examples Related to example datasets and dashboards label Aug 22, 2026
@bito-code-review

bito-code-review Bot commented Aug 22, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #5e9c60

Actionable Suggestions - 0
Review Details
  • Files reviewed - 5 · Commit Range: 8d181bf..92972ed
    • superset/common/form_data_query_context.py
    • superset/examples/birth_names.py
    • superset/examples/usa_births_names/charts/Boys.yaml
    • superset/examples/usa_births_names/charts/Girls.yaml
    • tests/unit_tests/common/test_form_data_query_context.py
  • Files skipped - 0
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers an incremental AI Review.

  • /review full - Manually triggers a full AI Review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

@codecov

codecov Bot commented Aug 22, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.85%. Comparing base (f2610e9) to head (92972ed).

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #43422      +/-   ##
==========================================
- Coverage   78.85%   78.85%   -0.01%     
==========================================
  Files        2876     2876              
  Lines      164581   164581              
  Branches    38011    38011              
==========================================
- Hits       129786   129784       -2     
- Misses      32348    32350       +2     
  Partials     2447     2447              
Flag Coverage Δ
hive 38.08% <0.00%> (ø)
mysql 57.77% <0.00%> (ø)
postgres 57.80% <0.00%> (-0.01%) ⬇️
presto 40.01% <0.00%> (ø)
python 83.54% <100.00%> (-0.01%) ⬇️
sqlite 57.49% <0.00%> (ø)
unit 73.56% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@aminghadersohi aminghadersohi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the diff — the core fix is correct and well-tested (fail-before/pass-after tests confirm the orderby_from_form_data fallback, and the example renames are consistent across birth_names.py and the YAML fixtures). Approving, with two non-blocking notes for a possible follow-up:

  1. superset/common/form_data_query_context.py:216 — this is now a third independent reimplementation of the timeseries_limit_metric → series_limit_metric fallback, alongside query_object.py's DEPRECATED_FIELDS/_rename_deprecated_fields (old field wins if both present) and models/helpers.py's series_limit_metric or timeseries_limit_metric (new field wins). This new code also matches models/helpers.py's precedence but is the opposite of query_object.py's, and it drops the deprecation-usage logger.warning that query_object.py emits. Worth a follow-up to consolidate into a shared helper so future deprecated-field renames don't need a 4th copy.
  2. tests/unit_tests/common/test_form_data_query_context.py:218-234 — the pre-existing test_orderby_uses_timeseries_limit_metric_and_order_desc and the two new tests differ only in which key(s) populate form_data, all asserting the same orderby result. Could be collapsed into one @pytest.mark.parametrize test.

Neither blocks this PR — both are pre-existing patterns/observations rather than regressions introduced here.

@eschutho
eschutho merged commit 9f505eb into master Aug 22, 2026
81 checks passed
@eschutho
eschutho deleted the fix/birth-names-series-limit-metric branch August 22, 2026 22:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc:examples Related to example datasets and dashboards preset-io size/M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants