refactor(chart): replace word cloud sort_by_series migration with code defaults#39575
Conversation
…e defaults Follow-up to #39073. That PR added a DB migration (fd0c8583b46d) to set sort_by_series=true on every existing word_cloud slice so their legacy ordering was preserved. The same backward-compatibility guarantee can be achieved with two small code changes, making the fix cherry-pickable onto release branches without dragging along intermediate migrations. Changes: - controlPanel.tsx: sort_by_series default flips from false to true, so new charts match the pre-fix behavior (series ORDER BY appended). Users opt out for the Druid TopN fast path by unchecking the box. - buildQuery.ts: series-sort check becomes `sort_by_series !== false` so legacy charts rendered on dashboards (where Explore's control-state hydration does not run and the param is undefined in form_data) still get the legacy ordering. - controlPanel.test.ts: locks the default: true invariant against future accidental flips that would break legacy charts. - Migration fd0c8583b46d is deleted entirely — no downstream migration referenced it, so the Alembic chain is unaffected. Trade-off: new charts default to the slow (legacy) ordering, matching the pre-#39073 behavior. The original PR's new-chart fast-path default is deferred; users can still opt in per-chart. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Code Review Agent Run #c22da1Actionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #39575 +/- ##
=======================================
Coverage 64.54% 64.54%
=======================================
Files 2565 2565
Lines 133649 133651 +2
Branches 31050 31052 +2
=======================================
+ Hits 86267 86269 +2
Misses 45890 45890
Partials 1492 1492
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR refactors Word Cloud’s sort_by_series backward-compatibility approach by replacing a database migration with code-level defaults, so legacy charts keep their pre-#39073 ordering behavior without requiring schema/data changes.
Changes:
- Flip the Word Cloud
sort_by_seriescontrol default totrueso new charts match legacy ordering by default. - Update query building to treat
sort_by_series: undefinedas enabled (sort_by_series !== false) to preserve ordering for legacy dashboard-rendered charts. - Add unit tests to lock in the new default and legacy behavior; delete the previously-added migration.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
superset/migrations/versions/2026-04-13_19-28_fd0c8583b46d_add_sort_by_series_to_word_cloud_charts.py |
Removes the migration that previously backfilled sort_by_series=true into existing Word Cloud chart params. |
superset-frontend/plugins/plugin-chart-word-cloud/src/plugin/controlPanel.tsx |
Sets sort_by_series checkbox default to true and updates the help text to reflect the Druid TopN opt-out rationale. |
superset-frontend/plugins/plugin-chart-word-cloud/src/plugin/buildQuery.ts |
Treats missing sort_by_series as enabled by default to preserve legacy ordering. |
superset-frontend/plugins/plugin-chart-word-cloud/test/controlPanel.test.ts |
Adds a test asserting sort_by_series defaults to true. |
superset-frontend/plugins/plugin-chart-word-cloud/test/buildQuery.test.ts |
Adds a test asserting legacy charts (missing sort_by_series) still order by series. |
Comments suppressed due to low confidence (1)
superset/migrations/versions/2026-04-13_19-28_fd0c8583b46d_add_sort_by_series_to_word_cloud_charts.py:1
- Deleting an Alembic revision file can break
superset db upgrade/downgradefor any environment that already ran this revision (theiralembic_versiontable will referencefd0c8583b46d, and Alembic will error because it can’t locate the revision script). Even if no later migrations depend on it, the file should generally remain in-tree for history/upgrade-path integrity.
Consider keeping this revision file (it can be a no-op, or keep the existing param-update logic) and relying on the code defaulting for backward-compat going forward. If the goal is cherry-picking to release branches, omit the migration only on those branches where it never shipped, but avoid removing it from branches where it may have been applied.
Fix tsc failure: the ad-hoc type predicate narrowed to a type that isn't assignable to ControlSetItem. Reuse the exported isCustomControlItem guard from @superset-ui/chart-controls, matching the pattern used in ControlPanelsContainer. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
09f5d01 to
da4e924
Compare
Code Review Agent Run #8a9042Actionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
Reverts the Druid-specific wording per reviewer feedback — the "some databases" phrasing is more engine-agnostic. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Code Review Agent Run #a6ae9dActionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
…d21901ab Master just removed the ``fd0c8583b46d`` (``add_sort_by_series_to_word_cloud_charts``) migration in apache#39575 ("refactor(chart): replace word cloud sort_by_series migration with code defaults"), replacing the run-time data migration with TS-side defaults in the word-cloud plugin. The parent migration ``ce6bd21901ab`` (``migrate_deckgl_and_mapbox``) is now master's tip. Our ``56cd24c07170`` (``add_entity_version_history_tables``) still pointed at ``fd0c8583b46d`` as its ``down_revision``. Once this PR merges into the post-apache#39575 master, that reference dangles and Alembic fails to build the revision map with ``KeyError: 'fd0c8583b46d'`` on every DB-backed job (test-sqlite, test-postgres, test-mysql, etc.). Repoints ``56cd24c07170``'s ``down_revision`` at ``ce6bd21901ab``. Also includes the rebase onto the current master head, which drops the ``fd0c8583b46d`` migration file so the local chain matches what CI sees. Verified locally: ``superset db upgrade`` runs the full chain clean (``ce6bd21901ab -> 56cd24c07170 -> 04ea0c58fcb9 -> 8b2a1c3d4e5f -> c9d7e21a4b3f -> d8e9f0a1b2c3``); 50 versioning integration tests and 25 unit tests still pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…d21901ab Master just removed the ``fd0c8583b46d`` (``add_sort_by_series_to_word_cloud_charts``) migration in apache#39575 ("refactor(chart): replace word cloud sort_by_series migration with code defaults"), replacing the run-time data migration with TS-side defaults in the word-cloud plugin. The parent migration ``ce6bd21901ab`` (``migrate_deckgl_and_mapbox``) is now master's tip. Our ``56cd24c07170`` (``add_entity_version_history_tables``) still pointed at ``fd0c8583b46d`` as its ``down_revision``. Once this PR merges into the post-apache#39575 master, that reference dangles and Alembic fails to build the revision map with ``KeyError: 'fd0c8583b46d'`` on every DB-backed job (test-sqlite, test-postgres, test-mysql, etc.). Repoints ``56cd24c07170``'s ``down_revision`` at ``ce6bd21901ab``. Also includes the rebase onto the current master head, which drops the ``fd0c8583b46d`` migration file so the local chain matches what CI sees. Verified locally: ``superset db upgrade`` runs the full chain clean (``ce6bd21901ab -> 56cd24c07170 -> 04ea0c58fcb9 -> 8b2a1c3d4e5f -> c9d7e21a4b3f -> d8e9f0a1b2c3``); 50 versioning integration tests and 25 unit tests still pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…d21901ab Master just removed the ``fd0c8583b46d`` (``add_sort_by_series_to_word_cloud_charts``) migration in apache#39575 ("refactor(chart): replace word cloud sort_by_series migration with code defaults"), replacing the run-time data migration with TS-side defaults in the word-cloud plugin. The parent migration ``ce6bd21901ab`` (``migrate_deckgl_and_mapbox``) is now master's tip. Our ``56cd24c07170`` (``add_entity_version_history_tables``) still pointed at ``fd0c8583b46d`` as its ``down_revision``. Once this PR merges into the post-apache#39575 master, that reference dangles and Alembic fails to build the revision map with ``KeyError: 'fd0c8583b46d'`` on every DB-backed job (test-sqlite, test-postgres, test-mysql, etc.). Repoints ``56cd24c07170``'s ``down_revision`` at ``ce6bd21901ab``. Also includes the rebase onto the current master head, which drops the ``fd0c8583b46d`` migration file so the local chain matches what CI sees. Verified locally: ``superset db upgrade`` runs the full chain clean (``ce6bd21901ab -> 56cd24c07170 -> 04ea0c58fcb9 -> 8b2a1c3d4e5f -> c9d7e21a4b3f -> d8e9f0a1b2c3``); 50 versioning integration tests and 25 unit tests still pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…d21901ab Master just removed the ``fd0c8583b46d`` (``add_sort_by_series_to_word_cloud_charts``) migration in apache#39575 ("refactor(chart): replace word cloud sort_by_series migration with code defaults"), replacing the run-time data migration with TS-side defaults in the word-cloud plugin. The parent migration ``ce6bd21901ab`` (``migrate_deckgl_and_mapbox``) is now master's tip. Our ``56cd24c07170`` (``add_entity_version_history_tables``) still pointed at ``fd0c8583b46d`` as its ``down_revision``. Once this PR merges into the post-apache#39575 master, that reference dangles and Alembic fails to build the revision map with ``KeyError: 'fd0c8583b46d'`` on every DB-backed job (test-sqlite, test-postgres, test-mysql, etc.). Repoints ``56cd24c07170``'s ``down_revision`` at ``ce6bd21901ab``. Also includes the rebase onto the current master head, which drops the ``fd0c8583b46d`` migration file so the local chain matches what CI sees. Verified locally: ``superset db upgrade`` runs the full chain clean (``ce6bd21901ab -> 56cd24c07170 -> 04ea0c58fcb9 -> 8b2a1c3d4e5f -> c9d7e21a4b3f -> d8e9f0a1b2c3``); 50 versioning integration tests and 25 unit tests still pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…d21901ab Master just removed the ``fd0c8583b46d`` (``add_sort_by_series_to_word_cloud_charts``) migration in apache#39575 ("refactor(chart): replace word cloud sort_by_series migration with code defaults"), replacing the run-time data migration with TS-side defaults in the word-cloud plugin. The parent migration ``ce6bd21901ab`` (``migrate_deckgl_and_mapbox``) is now master's tip. Our ``56cd24c07170`` (``add_entity_version_history_tables``) still pointed at ``fd0c8583b46d`` as its ``down_revision``. Once this PR merges into the post-apache#39575 master, that reference dangles and Alembic fails to build the revision map with ``KeyError: 'fd0c8583b46d'`` on every DB-backed job (test-sqlite, test-postgres, test-mysql, etc.). Repoints ``56cd24c07170``'s ``down_revision`` at ``ce6bd21901ab``. Also includes the rebase onto the current master head, which drops the ``fd0c8583b46d`` migration file so the local chain matches what CI sees. Verified locally: ``superset db upgrade`` runs the full chain clean (``ce6bd21901ab -> 56cd24c07170 -> 04ea0c58fcb9 -> 8b2a1c3d4e5f -> c9d7e21a4b3f -> d8e9f0a1b2c3``); 50 versioning integration tests and 25 unit tests still pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…d21901ab Master just removed the ``fd0c8583b46d`` (``add_sort_by_series_to_word_cloud_charts``) migration in apache#39575 ("refactor(chart): replace word cloud sort_by_series migration with code defaults"), replacing the run-time data migration with TS-side defaults in the word-cloud plugin. The parent migration ``ce6bd21901ab`` (``migrate_deckgl_and_mapbox``) is now master's tip. Our ``56cd24c07170`` (``add_entity_version_history_tables``) still pointed at ``fd0c8583b46d`` as its ``down_revision``. Once this PR merges into the post-apache#39575 master, that reference dangles and Alembic fails to build the revision map with ``KeyError: 'fd0c8583b46d'`` on every DB-backed job (test-sqlite, test-postgres, test-mysql, etc.). Repoints ``56cd24c07170``'s ``down_revision`` at ``ce6bd21901ab``. Also includes the rebase onto the current master head, which drops the ``fd0c8583b46d`` migration file so the local chain matches what CI sees. Verified locally: ``superset db upgrade`` runs the full chain clean (``ce6bd21901ab -> 56cd24c07170 -> 04ea0c58fcb9 -> 8b2a1c3d4e5f -> c9d7e21a4b3f -> d8e9f0a1b2c3``); 50 versioning integration tests and 25 unit tests still pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Master removed the word-cloud sort_by_series migration in apache#39575 (replaced its effect with code defaults), so the previous a3b4c5d6e7f8 merge — which referenced fd0c8583b46d — became invalid. After dropping it, two heads remained: cb39f18af67f (sc-103157 soft delete) and 33d7e0e21daa (semantic layers and views), both descending from ce6bd21901ab. Empty merge migration unifies them so ``superset db upgrade head`` has an unambiguous target. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Master removed the word-cloud sort_by_series migration in apache#39575 (replaced its effect with code defaults), so the previous a3b4c5d6e7f8 merge — which referenced fd0c8583b46d — became invalid. After dropping it, two heads remained: cb39f18af67f (sc-103157 soft delete) and 33d7e0e21daa (semantic layers and views), both descending from ce6bd21901ab. Empty merge migration unifies them so ``superset db upgrade head`` has an unambiguous target. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Master removed the word-cloud sort_by_series migration in apache#39575 (replaced its effect with code defaults), so the previous a3b4c5d6e7f8 merge — which referenced fd0c8583b46d — became invalid. After dropping it, two heads remained: cb39f18af67f (sc-103157 soft delete) and 33d7e0e21daa (semantic layers and views), both descending from ce6bd21901ab. Empty merge migration unifies them so ``superset db upgrade head`` has an unambiguous target. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
SUMMARY
Follow-up to #39073. That PR fixed the Word Cloud secondary-sort issue on Druid by adding an independent
sort_by_seriescontrol, and shipped a DB migration (fd0c8583b46d) to setsort_by_series=trueon every existingword_cloudslice so their legacy ordering was preserved.The same backward-compatibility guarantee can be achieved with two small code changes — making the fix cherry-pickable onto release branches without dragging along the intermediate migrations that would otherwise need to come with it.
Changes:
controlPanel.tsx:sort_by_seriesdefault flips fromfalse→true. New charts now match the pre-fix behavior (seriesORDER BYappended). Users opt out for the Druid TopN fast path by unchecking the box.buildQuery.ts: series-sort check becomessort_by_series !== falseso legacy charts rendered on dashboards — where Explore's control-state hydration does not run and the param isundefinedinform_data— still get the legacy ordering.controlPanel.test.ts: locks thedefault: trueinvariant against future accidental flips that would break legacy charts.fd0c8583b46dis deleted entirely — no downstream migration referenced it, so the Alembic chain is unaffected.Why replace the migration with code? For JSON-blob params like
slice.params, a migration is only strictly required when "field absent" doesn't have a well-defined meaning in the reader. Here we can defineundefined → trueat read time and get the same outcome without touching any row in the DB.Trade-off: new charts default to the slow (legacy) ordering, matching pre-#39073 behavior. The original PR's new-chart fast-path default is deferred; users can still opt in per-chart. This is the right call for cherry-pickability — the fix (the opt-out box) is available to everyone, the new default isn't.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Not applicable — no visual change to the word cloud rendering or control panel beyond the default checkbox state.
TESTING INSTRUCTIONS
Frontend unit tests:
Manual:
/api/v1/chart/datapayload for a legacy chart on a dashboard: theorderbyarray should include the series sort even though the savedparamshas nosort_by_serieskey.ORDER BY <series> ASC."sort_by_series": falseand the query should have no seriesORDER BY.ADDITIONAL INFORMATION
🤖 Generated with Claude Code