Repository navigation
fix(semantic-layer): report incompatible dashboard filters on semantic views instead of dropping them - #45105
Conversation
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%.
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov Report❌ Patch coverage is
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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@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 PR Risk: Medium Risk
Assessed commit: |
fitzee
left a comment
There was a problem hiding this comment.
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 theSemanticQuery. Whengranularityis set, aTEMPORAL_RANGEfilter 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 inQueryObject.validate(),_validate_filters,map_query_objectandmap_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: trueto 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 inUPDATING.mdnext to the semantic-view entry.
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]>
|
Thanks for the detailed review. Pushed the follow-up in 80b95a5. Finding 1 (MCP provenance): Fixed at the shared point: 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 Nits: Added the 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. |
aminghadersohi
left a comment
There was a problem hiding this comment.
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?
|
Thanks @aminghadersohi — the The |
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.
|
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. |
aminghadersohi
left a comment
There was a problem hiding this comment.
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.
…metric-filters # Conflicts: # UPDATING.md # superset/semantic_layers/mapper.py
|
Rechecked the CodeAnt SQL-badge concern on a9ed7b9. The selector retains incompatible indicators, but The paired Table/SemanticView regression verifies that the same rejected-only response renders no SQL badge and renders Checked by Codex on Mike’s behalf. |
SUMMARY
Semantic-view filters should never be silently discarded. This change distinguishes dashboard filters from predicates defined by the chart:
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
SEMANTIC_LAYERSand use a semantic view with a dimension such ascategoryand a metric such astotal_amount. Create a chart using that view.categoryfilter. Confirm it restricts the result and is reported as applied; an incompatible filter alongside it remains reported as incompatible.{"col":"total_amount","op":">=","val":999999}. Confirm a 400 error names the metric, including when the same request also contains a valid dimension filter.isExtra: false). Confirm its query payload has no false provenance field and its behavior is unchanged.Automated verification:
ADDITIONAL INFORMATION
SEMANTIC_LAYERSfor semantic-view functionality; the incompatible-filter badge is scoped to semantic-view charts.Compatibility and rollout:
UPDATING.mddescribe this correction.Implementation assisted by Codex; independently reviewed with Claude.
🤖 Generated with Claude Code