Skip to content

fix(dashboard): apply dynamic groupby display controls to scoped charts#39356

Open
richardfogaca wants to merge 4 commits intoapache:masterfrom
richardfogaca:fix/dashboard-dynamic-groupby-core
Open

fix(dashboard): apply dynamic groupby display controls to scoped charts#39356
richardfogaca wants to merge 4 commits intoapache:masterfrom
richardfogaca:fix/dashboard-dynamic-groupby-core

Conversation

@richardfogaca
Copy link
Copy Markdown
Contributor

@richardfogaca richardfogaca commented Apr 14, 2026

SUMMARY

  • Fix dynamic group-by query generation so selected columns are applied as chart dimensions instead of being injected as spurious row filters.
  • Allow valid group-by selections even when the selected column already exists in the chart's base groupby.
  • Normalize single-select values so scoped charts receive the expected groupby array shape.
  • Migrate legacy chart customization items before scope calculation so in-scope charts are actually updated.
  • Add direct regression coverage for getFormDataWithExtraFilters and DashboardContainer.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

BEFORE

Selecting status should only change the chart grouping. Before this fix, the frontend could also treat status as a row filter value
bugfix-before-status-selected

AFTER

The same interaction now updates groupby correctly without adding the bogus status IN ('status') filter.
bugfix-before-after-apply

TESTING INSTRUCTIONS

  1. Create an aggregate table chart with a groupby field and add it to a dashboard.
  2. Add a Dynamic Group By display control scoped to that chart.
  3. Select a column and click Apply Filters.
  4. Expected: the chart re-queries with the selected column in groupby and without a spurious filters clause containing the selected column name as a value.
  5. Also verify legacy dashboard metadata still scopes the customization correctly.

Automated:

  • npm run test -- src/dashboard/util/getFormDataWithExtraFilters.test.ts
  • npm run test -- src/dashboard/components/DashboardBuilder/DashboardContainer.test.tsx

Validation note:

  • pre-commit run --all-files was executed in the isolated worktree, but the frontend type-check step hits existing baseline declaration issues unrelated to this patch (dom-to-image-more / dom-to-pdf resolution in src/utils/downloadAsImage.tsx and src/utils/downloadAsPdf.ts).

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

Copilot AI review requested due to automatic review settings April 14, 2026 22:18
@bito-code-review
Copy link
Copy Markdown
Contributor

bito-code-review bot commented Apr 14, 2026

Code Review Agent Run #3efc58

Actionable Suggestions - 0
Additional Suggestions - 1
  • superset-frontend/src/dashboard/util/getFormDataWithExtraFilters.test.ts - 1
    • Missing return type hints · Line 25-66
      Helper functions should include explicit return type hints for consistency and type safety, as per project guidelines.
      Code suggestion
       @@ -25,5 +25,5 @@
        const expectGroupBy = (
          result: CachedFormDataWithExtraControls,
          expected: unknown,
      - ) => {
      + ): void => {
          expect('groupby' in result).toBe(true);
          if (!('groupby' in result)) {
            throw new Error('Expected groupby to be present in form data');
          }
          expect(result.groupby).toEqual(expected);
        };
       @@ -36,5 +36,5 @@
        const expectGroupByLength = (
          result: CachedFormDataWithExtraControls,
          length: number,
      - ) => {
      + ): void => {
          expect('groupby' in result).toBe(true);
          if (!('groupby' in result)) {
            throw new Error('Expected groupby to be present in form data');
          }
          expect(result.groupby).toHaveLength(length);
        };
       @@ -47,2 +47,2 @@
        const getResultFilters = (result: CachedFormDataWithExtraControls) => {
      + const getResultFilters = (result: CachedFormDataWithExtraControls): {col: string; val: unknown[]}[] => {
          if (!('filters' in result) || !Array.isArray(result.filters)) {
            return [];
          }
          return result.filters.filter(
            (
              filter,
            ): filter is {
              col: string;
              val: unknown[];
            } =>
              typeof filter === 'object' &&
              filter !== null &&
              'col' in filter &&
              'val' in filter &&
              typeof filter.col === 'string' &&
              Array.isArray(filter.val),
          );
        };
Review Details
  • Files reviewed - 4 · Commit Range: aaffada..aaffada
    • superset-frontend/src/dashboard/components/DashboardBuilder/DashboardContainer.test.tsx
    • superset-frontend/src/dashboard/components/DashboardBuilder/DashboardContainer.tsx
    • superset-frontend/src/dashboard/util/charts/getFormDataWithExtraFilters.ts
    • superset-frontend/src/dashboard/util/getFormDataWithExtraFilters.test.ts
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • Eslint (Linter) - ✔︎ Successful

Bito Usage Guide

Commands

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

  • /review - 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

@dosubot dosubot bot added change:frontend Requires changing the frontend dashboard Namespace | Anything related to the Dashboard labels Apr 14, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes dashboard Dynamic Group By display controls so scoped charts receive correct groupby updates (and no longer get incorrect filter injections), including improved handling of legacy chart customization metadata.

Changes:

  • Remove the spurious “selected column as filter value” injection path and ensure dynamic group-by selections are applied as chart dimensions.
  • Normalize single-select dynamic group-by values (string → one-item array) and deduplicate chord groupby.
  • Normalize/migrate legacy chart customization config before scope calculation, and add regression tests for getFormDataWithExtraFilters and DashboardContainer.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
superset-frontend/src/dashboard/util/getFormDataWithExtraFilters.test.ts Adds focused regression coverage for dynamic group-by behavior and scoping edge cases.
superset-frontend/src/dashboard/util/charts/getFormDataWithExtraFilters.ts Fixes dynamic group-by form-data generation (remove filter injection, normalize single-select, chord dedupe).
superset-frontend/src/dashboard/components/DashboardBuilder/DashboardContainer.tsx Migrates legacy chart customization items before scope calculation.
superset-frontend/src/dashboard/components/DashboardBuilder/DashboardContainer.test.tsx Adds tests validating charts-in-scope calculation for chart customizations, including legacy format migration.
Comments suppressed due to low confidence (1)

superset-frontend/src/dashboard/components/DashboardBuilder/DashboardContainer.tsx:212

  • The legacy normalization + calculateScopes path can incorrectly expand a legacy chart customization that was previously scoped via chartId. migrateChartCustomization() sets chartsInScope: [legacy.chartId], but calculateScopes() ignores chartsInScope and recomputes it solely from item.scope; the migrated legacy scope defaults to { rootPath: [DASHBOARD_ROOT_ID], excluded: [] }, which will put all charts in scope and then setInScopeStatusOfCustomizations persists that broadened scope back into metadata.

To preserve legacy per-chart scoping, consider special-casing legacy items that include chartId when building normalizedCustomizations (e.g., after migration, set scope.excluded to chartIds.filter(id => id !== legacy.chartId) or otherwise derive a scope that yields only the intended chart(s) in calculateScopes).

    // Normalize legacy chart customizations before scope calculation.
    const hasLegacy = chartCustomizations.some(
      isLegacyChartCustomizationFormat,
    );
    const normalizedCustomizations = hasLegacy
      ? migrateChartCustomizationArray(chartCustomizations)
      : chartCustomizations;

    const scopes = calculateScopes(
      normalizedCustomizations,
      chartIds,
      chartLayoutItems,
      item => item.type === ChartCustomizationType.Divider,
    ).map(scope => ({

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 14, 2026

Codecov Report

❌ Patch coverage is 80.95238% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.54%. Comparing base (3e25f02) to head (e2cb057).

Files with missing lines Patch % Lines
...shboard/util/charts/getFormDataWithExtraFilters.ts 66.66% 3 Missing ⚠️
...components/DashboardBuilder/DashboardContainer.tsx 91.66% 1 Missing ⚠️

❌ Your project check has failed because the head coverage (99.81%) is below the target coverage (100.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #39356      +/-   ##
==========================================
+ Coverage   64.45%   64.54%   +0.09%     
==========================================
  Files        2555     2555              
  Lines      132721   132730       +9     
  Branches    30802    30808       +6     
==========================================
+ Hits        85539    85667     +128     
+ Misses      45696    45577     -119     
  Partials     1486     1486              
Flag Coverage Δ
javascript 66.32% <80.95%> (+0.16%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 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.

@bito-code-review
Copy link
Copy Markdown
Contributor

bito-code-review bot commented Apr 14, 2026

Code Review Agent Run #4360c0

Actionable Suggestions - 0
Additional Suggestions - 1
  • superset-frontend/src/dashboard/util/getFormDataWithExtraFilters.test.ts - 1
    • Misleading test description · Line 332-337
      The test description claims it 'keeps the base groupby', but the expectation sets groupby to ['status'], replacing the base ['original_column']. This is misleading and should accurately describe that empty strings are ignored while valid selections are applied.
Review Details
  • Files reviewed - 4 · Commit Range: aaffada..067d7ad
    • superset-frontend/src/dashboard/components/DashboardBuilder/DashboardContainer.test.tsx
    • superset-frontend/src/dashboard/components/DashboardBuilder/DashboardContainer.tsx
    • superset-frontend/src/dashboard/util/charts/getFormDataWithExtraFilters.ts
    • superset-frontend/src/dashboard/util/getFormDataWithExtraFilters.test.ts
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • Eslint (Linter) - ✔︎ Successful

Bito Usage Guide

Commands

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

  • /review - 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

@bito-code-review
Copy link
Copy Markdown
Contributor

bito-code-review bot commented Apr 15, 2026

Code Review Agent Run #940d46

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: 067d7ad..e2cb057
    • superset-frontend/src/dashboard/util/charts/getFormDataWithExtraFilters.ts
    • superset-frontend/src/dashboard/util/getFormDataWithExtraFilters.test.ts
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • Eslint (Linter) - ✔︎ Successful

Bito Usage Guide

Commands

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

  • /review - 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:frontend Requires changing the frontend dashboard Namespace | Anything related to the Dashboard size/XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants