Skip to content

fix(matrixify): apply dimension filters to all query-specific adhoc filter collections - #43861

Merged
rusackas merged 3 commits into
apache:masterfrom
jenwitteng:matrixify-multiquery-adhoc-filters
Sep 22, 2026
Merged

rusackas merged 3 commits into
apache:masterfrom
jenwitteng:matrixify-multiquery-adhoc-filters

Conversation

@jenwitteng

Copy link
Copy Markdown
Contributor

SUMMARY

Matrixify builds a grid of chart cells, injecting a per-cell dimension filter (e.g. country == 'USA') into each cell's formData. That filter was appended only to adhoc_filters.

Charts with more than one query route each query through a separate adhoc-filter collection — Mixed Chart reads query A from adhoc_filters, query B from adhoc_filters_b, query C from adhoc_filters_c. As a result, on multi-query charts the Matrixify slice filter was silently dropped from every query except the first, so those cells rendered unfiltered data.

This change introduces appendMatrixifyFilters, which fans the injected filters out to adhoc_filters plus every adhoc_filters_* collection present on the formData, so all of a chart's queries are sliced by the cell's dimension value.

Design notes:

  • Non-array values on a matched key are treated as empty.
  • Each key is reassigned to a new array rather than mutating the shared base formData, so cells don't contaminate each other.
  • matrixify_* keys are deleted before the fan-out, so they can't be matched by the adhoc_filters_* pattern.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

N/A — behavior fix, no visual/layout change. Effect: Mixed Chart Matrixify cells now filter query B/C data to the cell's dimension value instead of showing the full, unfiltered series.

TESTING INSTRUCTIONS

Manual:

  1. Create a Mixed Chart (query A + query B).
  2. Enable Matrixify with a row dimension (e.g. country with 2+ values).
  3. Before this change: query B's series ignore the per-cell dimension filter (every cell shows the same B data). After: both query A and query B are filtered to the cell's dimension value.

Automated:

  • superset-ui-core/.../Matrixify/MatrixifyGridGenerator.test.ts — asserts the dimension filter reaches adhoc_filters, adhoc_filters_b, and adhoc_filters_c (including one that started empty), preserves pre-existing filters, and leaves look-alike keys such as filters_b untouched.
  • plugin-chart-echarts/test/MixedTimeseries/buildQuery.test.ts — asserts both compiled queries carry the Matrixify filter and query B's pre-existing free-form filter is preserved.

ADDITIONAL INFORMATION

  • Has associated issue: Fixes 6.1.0rc1 - matrixify not applying to query B in Mixed Chart #39007
  • 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

…ilter collections

Matrixify builds a grid of chart cells, injecting a per-cell dimension
filter (e.g. country == 'USA') into each cell's formData. That filter was
appended only to `adhoc_filters`, so charts with more than one query -- e.g.
Mixed Chart, whose query B reads `adhoc_filters_b` and query C reads
`adhoc_filters_c` -- silently dropped the slice filter from every query
except the first, rendering unfiltered data in those cells.

Fan the injected filters out to `adhoc_filters` plus every `adhoc_filters_*`
collection present on the formData, so all of a chart's queries are sliced.
Non-array values on a matched key are treated as empty, and the reassignment
creates new arrays rather than mutating the shared base formData.

Adds a MatrixifyGridGenerator unit test asserting the filter reaches every
adhoc_filters_* collection (and leaves look-alike keys untouched), plus a
Mixed Chart buildQuery test verifying both compiled queries are filtered.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Signed-off-by: Jenwit Amonpongitsara <[email protected]>
@bito-code-review

bito-code-review Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #fc048a

Actionable Suggestions - 0
Additional Suggestions - 2
  • superset-frontend/packages/superset-ui-core/src/chart/components/Matrixify/MatrixifyGridGenerator.ts - 2
    • Unsound type guard · Line 107-109
      `isAdhocFilterArray` declares `value is AdhocFilter[]` but only checks `Array.isArray`, so the type predicate is unsound and the name overstates what is validated. Since the value is spread into an `AdhocFilter[]` array, prefer `Array.isArray(existingFilters)` inline and drop the helper, or rename it to avoid implying element validation.
    • Object injection risk in dynamic key assignment · Line 129-130
      The linter flags potential object injection (CWE-1321) when assigning to `filterFields[key]` with a dynamic key. Although the regex restricts keys to `adhoc_filters_*`, it's safer to use `Object.defineProperty` to avoid prototype pollution. Consider using a `Map` or adding a key validation.
Review Details
  • Files reviewed - 3 · Commit Range: f6dba62..f6dba62
    • superset-frontend/packages/superset-ui-core/src/chart/components/Matrixify/MatrixifyGridGenerator.test.ts
    • superset-frontend/packages/superset-ui-core/src/chart/components/Matrixify/MatrixifyGridGenerator.ts
    • superset-frontend/plugins/plugin-chart-echarts/test/MixedTimeseries/buildQuery.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 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 [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

@codecov

codecov Bot commented Sep 4, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.42%. Comparing base (8d0637e) to head (028012b).
⚠️ Report is 405 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #43861   +/-   ##
=======================================
  Coverage   79.42%   79.42%           
=======================================
  Files        2895     2895           
  Lines      167997   168006    +9     
  Branches    38903    38903           
=======================================
+ Hits       133434   133443    +9     
  Misses      32064    32064           
  Partials     2499     2499           
Flag Coverage Δ
javascript 74.94% <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.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Signed-off-by: Jenwit Amonpongitsara <[email protected]>
@bito-code-review

bito-code-review Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #2c02d9

Actionable Suggestions - 0
Review Details
  • Files reviewed - 1 · Commit Range: f6dba62..f7558ad
    • superset-frontend/plugins/plugin-chart-echarts/test/MixedTimeseries/buildQuery.test.ts
  • Files skipped - 0
  • Tools
    • Eslint (Linter) - ✔︎ 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 [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

@bito-code-review

Copy link
Copy Markdown
Contributor

The current implementation of appendMatrixifyFilters does indeed modify the formData object in place by creating new arrays for each filter key and assigning them back to the formData object.

Regarding the concern about multiple countries: the generateMatrixifyGrid function iterates over the dimension values (e.g., ['USA', 'Canada']) and calls generateCellFormData for each. Since generateCellFormData creates a new cellFormData object (typically via cloning or spreading the original formData), the appendMatrixifyFilters function operates on this new, cell-specific object. Therefore, the filters are not accumulated across different cells, and each cell correctly receives only its own country filter while preserving the original adhoc_filters_b content from the base formData.

superset-frontend/packages/superset-ui-core/src/chart/components/Matrixify/MatrixifyGridGenerator.ts

function appendMatrixifyFilters(
  formData: QueryFormData & MatrixifyFormData,
  additionalFilters: AdhocFilter[],
): void {
  const filterFields: Record<string, unknown> = formData;
  const filterKeys = [
    'adhoc_filters',
    ...Object.keys(filterFields).filter(key => /^adhoc_filters_.+$/u.test(key)),
  ];

  filterKeys.forEach(key => {
    const existingFilters = filterFields[key];
    filterFields[key] = [
      ...(isAdhocFilterArray(existingFilters) ? existingFilters : []),
      ...additionalFilters,
    ];
  });
}

…cells

Covers a mutation scenario a single-value test couldn't catch: if the
adhoc_filters fan-out mutated a shared array reference instead of
writing a fresh array per cell, a USA/Canada dimension grid would
accumulate both countries' predicates in every cell's query-specific
filter collections.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Signed-off-by: Jenwit Amonpongitsara <[email protected]>
@netlify

netlify Bot commented Sep 18, 2026

Copy link
Copy Markdown

✅ Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 028012b
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6aacd985237a2f0009eef32b
😎 Deploy Preview https://deploy-preview-43861--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@bito-code-review

bito-code-review Bot commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #a6244d

Actionable Suggestions - 0
Review Details
  • Files reviewed - 1 · Commit Range: f7558ad..028012b
    • superset-frontend/packages/superset-ui-core/src/chart/components/Matrixify/MatrixifyGridGenerator.test.ts
  • Files skipped - 0
  • Tools
    • Eslint (Linter) - ✔︎ 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 [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

@rusackas rusackas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks, @jenwitteng. LGTM! Sneaky bug, nice work tracking it down to the query-specific adhoc_filters_* collections. Also glad @sadpandajoe's two-country test case landed before merge, that was the real edge case here.

@rusackas
rusackas merged commit 600db8e into apache:master Sep 22, 2026
83 checks passed
villebro pushed a commit that referenced this pull request Sep 22, 2026
…ilter collections (#43861)

Signed-off-by: Jenwit Amonpongitsara <[email protected]>
Co-authored-by: Claude Opus 4.8 <[email protected]>
(cherry picked from commit 600db8e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6.1.0rc1 - matrixify not applying to query B in Mixed Chart

3 participants