Skip to content

fix(semantic-layer): report incompatible dashboard filters on semantic views instead of dropping them - #45105

Merged
aminghadersohi merged 13 commits into
apache:masterfrom
mikebridge:sc-119497-semantic-metric-filters
Oct 12, 2026
Merged

aminghadersohi merged 13 commits into
apache:masterfrom
mikebridge:sc-119497-semantic-metric-filters

Conversation

@mikebridge

@mikebridge mikebridge commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

SUMMARY

Semantic-view filters should never be silently discarded. This change distinguishes dashboard filters from predicates defined by the chart:

  • Dashboard native filters and cross-filters on columns that are not dimensions of the target semantic view—including metric names—are skipped and reported as Incompatible, while the chart continues to render.
  • A chart-defined filter on a semantic-view metric returns a clear error naming the metric. It is not silently ignored or translated into a HAVING predicate.
  • Unknown chart-defined columns are reported as rejected, matching SQL datasets. Valid dimension filters continue to apply, including when a metric has the same name.
  • Applied/rejected reporting survives result-cache hits, and unsupported chart-defined metric predicates are validated before a cached result can be returned.

The frontend preserves dashboard-filter provenance and shows incompatible filters in the chart's filter badge and detail popover. Chart-owned SQL filter payloads and cache keys remain unchanged.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Before: an unsupported semantic-view metric predicate could return unfiltered results without reporting the skipped filter, and a chart with only incompatible dashboard filters could have no visible filter badge.

After: chart-defined metric predicates return an explicit error; incompatible dashboard filters appear in the filter-detail popover, including when no filter was applied. The incompatible-filter badge and detail section are scoped to semantic-view charts; SQL-dataset charts retain their applied-only badge behavior.

No browser screenshots were captured. The display behavior is covered by React Testing Library tests.

TESTING INSTRUCTIONS

  1. Enable SEMANTIC_LAYERS and use a semantic view with a dimension such as category and a metric such as total_amount. Create a chart using that view.
  2. On a dashboard, apply a native filter or cross-filter whose column is not a dimension of that view. Confirm the chart still renders and its filter-detail popover lists the filter under Incompatible filters, even when it is the only filter.
  3. Apply a compatible category filter. Confirm it restricts the result and is reported as applied; an incompatible filter alongside it remains reported as incompatible.
  4. Send a chart-data request with a chart-owned filter such as {"col":"total_amount","op":">=","val":999999}. Confirm a 400 error names the metric, including when the same request also contains a valid dimension filter.
  5. Repeat supported/incompatible dashboard requests with result caching enabled. Confirm applied/rejected reporting remains visible on cache hits.
  6. On a SQL-dataset dashboard chart, apply only a rejected filter and confirm no filter badge appears. With applied filters, confirm the badge retains the applied-only count.
  7. Check an existing SQL chart with saved simple adhoc filters (isExtra: false). Confirm its query payload has no false provenance field and its behavior is unchanged.

Automated verification:

  • Backend HTTP and mapper tests cover rejection before cache access, mixed filters, metric/dimension name collisions, provider predicate preservation, and seeded applied-only/rejected-only cache entries. Provider/cache transport boundaries are mocked.
  • The semantic-layer package gate passed 816 tests with 100% coverage, including a restored group-limit test for a filter that conversion rejects. The focused mapper and HTTP filter tests passed 205 tests.
  • The affected query-builder, chart-controls, native-filter and badge Jest run passed: 174 suites, 1,592 tests, with one existing skipped test. This includes MixedTimeseries and the regression that compares serialized SQL payloads. The regression was observed failing before the fix.
  • An independent comparison against master found identical chart-owned SQL payloads through the Table, Timeseries and MixedTimeseries builders, with absent and false provenance.
  • The unchanged backend's full local unit run had 22,393 passing tests and three machine-specific baseline failures; CI remains the full-suite authority. No live-provider or browser acceptance run is claimed.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags: SEMANTIC_LAYERS for semantic-view functionality; the incompatible-filter badge is scoped to semantic-view charts.
  • 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

Compatibility and rollout:

  • Chart-owned semantic metric filters that previously appeared to work by silently dropping a predicate will return an error. Use a dimension filter or remove the unsupported predicate. Documentation and UPDATING.md describe this correction.
  • Dashboard-filtered SQL charts receive explicit dashboard provenance in their cache keys and can incur a one-time cache warm-up after deployment. Chart-owned SQL filters retain their previous payloads and keys.
  • During a mixed-version frontend rollout, an old bundle may omit dashboard provenance. A dashboard filter whose name collides with a semantic-view metric can then be treated as chart-owned and return an error until the browser reloads the updated bundle.

Implementation assisted by Codex; independently reviewed with Claude.

🤖 Generated with Claude Code

SC-119497: non-dimension filters were silently removed, presenting unfiltered results as success. Reject metric-only and unknown names with a readable client error, including before result-cache reads so historical partial-filter results cannot bypass validation.

Preserve dimension filtering and name collisions, cover HTTP and direct mapping with red-first tests, and document the saved-chart compatibility correction.
Follow Mike's SC-119497 review decision: skip and report dashboard filters that are not semantic dimensions, while refusing chart-defined metric predicates before cache reads. Match SQL datasets for unknown chart columns.

Preserve extra-filter provenance through query building, populate applied/rejected metadata without invalidating rejected-only cache hits, and expose incompatible filters in dashboard badges. Add red-first HTTP, cache, query-builder, selector and RTL coverage.
Address the SC-119497 r2 review: saved chart-owned adhoc filters carry isExtra false, but forwarding it changes SQL query payloads and cache keys and breaks MixedTimeseries. Preserve only true dashboard origin and cover legacy payload equality and mixed filter provenance.
Use an unknown-column equality predicate so the None-conversion path is exercised even when inner time bounds are emitted. The temporal fixture exited earlier and left the required semantic-layer coverage gate below 100%.
@github-actions github-actions Bot added i18n Namespace | Anything related to localization doc Namespace | Anything related to documentation packages labels Oct 8, 2026
@netlify

netlify Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit a9ed7b9
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6accfdb3ebc9c570efc3a90a
😎 Deploy Preview https://deploy-preview-45105--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.

@github-actions github-actions Bot added the requires:rebase Requires rebasing on top of current master label Oct 8, 2026
@codecov

codecov Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.82609% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 82.98%. Comparing base (cd526f9) to head (a9ed7b9).

Files with missing lines Patch % Lines
...ard/components/FiltersBadge/DetailsPanel/index.tsx 87.50% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #45105      +/-   ##
==========================================
+ Coverage   82.94%   82.98%   +0.03%     
==========================================
  Files        3023     3026       +3     
  Lines      195600   195832     +232     
  Branches    45600    45715     +115     
==========================================
+ Hits       162241   162510     +269     
+ Misses      30148    30111      -37     
  Partials     3211     3211              
Flag Coverage Δ
hive 34.84% <22.72%> (-0.01%) ⬇️
javascript 78.70% <95.83%> (+0.09%) ⬆️
mysql 52.93% <22.72%> (-0.01%) ⬇️
postgres 52.94% <22.72%> (-0.01%) ⬇️
presto 36.63% <22.72%> (-0.01%) ⬇️
python 86.57% <100.00%> (+<0.01%) ⬆️
sqlite 52.69% <22.72%> (-0.01%) ⬇️
unit 80.43% <100.00%> (+0.02%) ⬆️

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.

@mikebridge
mikebridge marked this pull request as ready for review October 8, 2026 21:29
@mikebridge

Copy link
Copy Markdown
Member Author

@aminghadersohi @rebenitez1802 ready for review: on a dashboard, filters on columns a semantic view doesn't have (including metrics) are now skipped and shown as 'Incompatible' on the filter badge, exactly like SQL datasets, instead of being silently dropped. A filter the chart itself defines on a metric gets a clear error. Applied/rejected filter columns are now reported for semantic views.

@codeant-ai-for-open-source

codeant-ai-for-open-source Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

CodeAnt PR Risk: Medium Risk

  • The PR needs attention before merging because filter-status handling may change SQL chart badges.
  • The cross-filter selector now retains incompatible filters, and the badge counts those indicators for every datasource, not just semantic views.

Assessed commit: a9ed7b9cdd14

@fitzee fitzee 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.

Verdict: COMMENT. The semantic-view reporting and the guard that rejects chart-owned metric filters are correct and well tested. Dashboard-filter provenance is lost on the server-side MCP path, and the badge change affects every SQL dashboard without screenshots.

What I checked at 674fdbf. On semantic views, every simple filter is reported exactly once: as applied if its column is a dimension, as rejected otherwise. Rejected filters are still dropped from the provider query (_convert_query_object_filter returns None), so the chart renders. A dimension that shares a name with a metric is still applied. The metric guard in QueryObject.validate() runs before the cache key and cache read, so an old entry cannot hide the new 400. Rejected-only cache entries now count as complete. rejected_filters only echoes columns the client sent, so nothing leaks. I mutation-tested three guards: the isExtra exemption, the rejected_filter_columns cache condition and the pre-cache validate_filter_columns call. Removing any one of them fails tests (3, 2 and 1 failures). The semantic-layer, common and charts unit suites pass, as do the touched Jest suites (31 suites).

Findings

1. Server-side MCP chart data drops isExtra, so a dashboard filter on a metric name returns 400 instead of Incompatible (superset/mcp_service/chart/chart_helpers.py:247-248, superset/utils/core.py:1546-1552)

The new exemption at superset/semantic_layers/mapper.py:1202 depends on isExtra. Only the frontend (buildQueryObject.ts:92,96) and apply_dashboard_filter_context set it. MCP get_chart_data with extra_form_data goes through merge_extra_form_data_filters_into_query → prepare_form_data_for_query. merge_extra_filters tags the adhoc filters isExtra: True, but split_adhoc_filters_into_base_filters then rebuilds them as {col, op, val}. I ran merge_extra_form_data_filters_into_query(q, {"filters": [{"col": "total_amount", ...}]}, 1, "semantic_view") and got {'col': 'total_amount', 'op': 'IN', 'val': [1]} with no isExtra. The dashboard filter is then treated as chart-owned, and validate_filter_columns raises "Filter column 'total_amount' is a metric". The UI would show Incompatible for the same filter. Fix: keep isExtra in split_adhoc_filters_into_base_filters, or tag the merged filters in merge_form_data_filters_into_query. Add a test for that path.

2. Badge change on all dashboards: needs screenshots and an explicit UX decision (FiltersBadge/index.tsx:296-301, DetailsPanel/index.tsx:180-199, nativeFilters/selectors.ts:384-388)

Before this PR, the badge listed only applied filters, and SQL charts already received rejected_filters. Now every SQL chart outside a cross-filter's or native filter's dataset gets a badge with "Incompatible filters (N)". Cross-filters are globally scoped by default, so on a mixed-dataset dashboard one cross-filter click puts a badge on every unrelated chart. The PR body says this is intended. Still, it is a visible change across all dashboards, not just semantic views, and the PR has "Changes UI" checked with no screenshots. Please add before/after screenshots of a SQL dashboard with cross-filtering across datasets.

Side note on the bot's "inflated count" comment: appliedCrossFilterIndicators in FiltersBadge filters on CrossFilterApplied, so incompatible cross-filters are counted once, under incompatibleIndicators. selectChartCrossFilters has no other caller, so I don't see double counting.

3. Unset filters are counted as Incompatible when another filter on the same column is rejected (nativeFilters/selectors.ts:337)

getStatus returns Incompatible before it checks hasValue. That was harmless while Incompatible was never shown; now it changes the count. Scenario: two native filters target country and only one has a value. The chart's dataset has no country, so the backend rejects it. I verified with selectNativeIndicatorsForChart that both filters come back INCOMPATIBLE, so the badge reads "Filters (2)" for one filter. The same applies to a cleared cross-filter whose filterState.filters still has the key. Suggested fix: if (column && hasValue && rejectedColumns?.has(column)).

Nits

  • superset/semantic_layers/mapper.py:319-329: "applied" is decided by whether the name is a dimension, not by whether a predicate reached the SemanticQuery. When granularity is set, a TEMPORAL_RANGE filter on a different temporal dimension is skipped (lines 508-513; bounds go to the granularity column), yet it is reported as applied. This is an edge case, but the stated goal is honest reporting.
  • get_dimensions() / get_metrics() now run in QueryObject.validate(), _validate_filters, map_query_object and map_semantic_result_to_query_result, which is 3-4 calls per query object, including on cache hits. That is fine if implementations memoize. If a provider fetches metadata remotely, building the sets once would help.
  • Adding isExtra: true to every dashboard-applied filter changes SQL chart cache keys, which means a one-time cold cache after deploy. The PR body mentions this; it is worth a line in UPDATING.md next to the semantic-view entry.

mikebridge and others added 4 commits October 8, 2026 23:25
Preserve both release notes and mapper imports; align the provider fixture with upstream opt-in result cache versioning.
Retain metric-filter release notes alongside upstream MCP limits and rebind notes.
…ore unset ones

MCP get_chart_data and get_chart_sql merge extra_form_data filters through
split_adhoc_filters_into_base_filters, which rebuilds them as {col, op, val}
and drops isExtra. A dashboard filter on a semantic-view metric name was then
treated as chart-owned and refused with a 400 instead of being reported as
incompatible. Tag those merged filters as dashboard filters again.

The filter badge counted an unset native filter or cleared cross-filter as
Incompatible when another filter on the same column was rejected. Only a
filter with a value can be incompatible.

Note in UPDATING.md that dashboard-applied filters now carry isExtra, so
chart cache keys for dashboard-filtered queries change once.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…filters

The previous fix tagged filters only in the saved-query merge helper, so the
unsaved and fallback MCP builders (get_chart_data, get_chart_sql and chart
previews) still lost isExtra when split_adhoc_filters_into_base_filters rebuilt
dashboard filters as {col, op, val}. Keep each source filter's isExtra in that
shared splitter instead, so dashboard filters stay marked on every path while
chart-owned filters are never tagged, and drop the blanket tag.

Cover the saved, table and echarts builder paths with a typed regression that
keeps a chart-owned metric filter alongside the dashboard one, and align the
UPDATING note with the MCP tools now covered.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot removed the requires:rebase Requires rebasing on top of current master label Oct 9, 2026
@mikebridge

Copy link
Copy Markdown
Member Author

Thanks for the detailed review. Pushed the follow-up in 80b95a5.

Finding 1 (MCP provenance): Fixed at the shared point: split_adhoc_filters_into_base_filters preserves each adhoc filter's isExtra when rebuilding {col, op, val}. This covers the saved-query merge and unsaved/fallback builders used by chart data, SQL and previews, without tagging chart-owned filters. The regression covers saved, table and timeseries paths, pairing dashboard metric filters with chart-owned metric filters that remain refused.

Finding 2 (badge on all dashboards): Agreed this is a visible change beyond semantic views. Before/after screenshots of SQL dashboard cross-filtering across datasets and the UX decision on badge behavior will follow separately; this follow-up does not change that behavior.

Finding 3 (unset filters): Good catch. Applied column && hasValue && rejectedColumns?.has(column) and added the two-filters/same-column regression: the valued filter is Incompatible and the unset one stays Unset.

Nits: Added the UPDATING.md cache warm-up note. Independently checked that absent/false provenance preserves chart-owned SQL filter payloads and cache keys, while dashboard provenance changes the key. The TEMPORAL_RANGE reporting edge case remains a separate follow-up. Repeated metadata lookups are unchanged; we could hoist them separately if they prove costly. Thanks also for checking the bot's double-count claim.

Verification: the previously failing real-builder probe now passes; focused Python checks had 759 passes and the known local timezone failure; 67 focused frontend tests and changed-file hooks passed. No browser screenshots or live-provider validation are claimed here.

@github-actions github-actions Bot added the requires:rebase Requires rebasing on top of current master label Oct 9, 2026

@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.

Needs a rebase; the only conflict with master is the UPDATING.md ## Next list. FiltersBadge has no semantic-view or flag check, so a plain SQL chart whose only dashboard filter is rejected now shows a "Filters (1)" badge: scope that to semantic views pending the UX call, or decide it here?

@mikebridge

Copy link
Copy Markdown
Member Author

Thanks @aminghadersohi — the UPDATING.md conflict was resolved by the ordinary master merge in 489a7a7, preserving both entries. The PR is currently mergeable.

The lint-frontend rerun also passed on that same commit, including TypeScript. No additional source changes were needed for the earlier declaration-build failure.

Keep SQL-dataset dashboards on their applied-only badge behavior, as requested by Amin's review and Fitz's finding 2 on apache#45105. Gate the incompatible list by the chart datasource type and cover both rejected-only SQL and semantic-view charts.
@mikebridge

Copy link
Copy Markdown
Member Author

Thanks @aminghadersohi and @fitzee — 615d32e scopes the incompatible-filter badge to semantic-view charts; SQL-dataset badges are unchanged, so the SQL-dashboard screenshot request no longer applies.

@github-actions github-actions Bot removed the requires:rebase Requires rebasing on top of current master label Oct 10, 2026

@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.

Badge scoping verified: forcing the semantic-view check on or off each fails one arm of the new test, and master's badge tests pass unchanged against this head. Prior findings are closed and all 68 check-run legs have concluded with no failures.

@github-actions github-actions Bot added the requires:rebase Requires rebasing on top of current master label Oct 11, 2026
…metric-filters

# Conflicts:
#	UPDATING.md
#	superset/semantic_layers/mapper.py
@github-actions github-actions Bot removed the requires:rebase Requires rebasing on top of current master label Oct 12, 2026
@mikebridge

Copy link
Copy Markdown
Member Author

Rechecked the CodeAnt SQL-badge concern on a9ed7b9. The selector retains incompatible indicators, but FiltersBadge includes them in the count and details only when the chart datasource is a semantic view. SQL charts receive an empty incompatible-indicator list and keep their applied-only badge behavior.

The paired Table/SemanticView regression verifies that the same rejected-only response renders no SQL badge and renders Filters (1) for the semantic view. All 48 focused badge, details-panel and selector tests passed on this head. The scoping code is unchanged from 615d32e, so no further code change is needed.

Checked by Codex on Mike’s behalf.

@aminghadersohi
aminghadersohi merged commit f923be7 into apache:master Oct 12, 2026
80 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc Namespace | Anything related to documentation i18n Namespace | Anything related to localization packages size/XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants