Skip to content

fix(semantic-layer): restore value suggestions for semantic view filters - #45109

Merged
aminghadersohi merged 5 commits into
apache:masterfrom
mikebridge:sc-121456-semantic-value-suggestions
Oct 13, 2026
Merged

aminghadersohi merged 5 commits into
apache:masterfrom
mikebridge:sc-121456-semantic-value-suggestions

Conversation

@mikebridge

Copy link
Copy Markdown
Member

SUMMARY

#44370 disabled column-value suggestions on every versioned semantic view. A saved selection's display title can exactly match a different member's current stable ID, so the server can't tell from the column name alone whether a saved filter refers to a current member. This PR restores suggestions for selections whose provenance can be checked.

How the column-values endpoint changes (GET /api/v1/datasource/<type>/<id>/column/<col>/values/):

  • It accepts an optional semantic_selection_version query parameter.
  • On a versioned semantic view, a missing or stale version gets the existing 200 response, with result: [] and suggestions_status: "unavailable_versioned_view". That response is returned before any cache read or provider call, as it is today.
  • A matching version enables the normal retrieval and search path.
  • The version is part of the values cache key, but only for versioned views, so cached values from an older identity version are never served after a version bump. The cache key for tables and unversioned views doesn't change.

How the frontend changes:

  • The value comes from the chart's own form_data.semantic_selection_version. It is never taken from the datasource metadata that was just fetched.
  • Explore stamps that marker only when it resets semantic selections, which rebuilds form data and clears filters. A chart that carries the current version therefore had its fields picked after reselection.
  • Both the Dnd filter control and the legacy adhoc filter control pass the marker through to the simple-tab value picker. The path is DndFilterSelect / AdhocFilterControl → filter option → popover trigger → edit popover → simple tab.
  • Matrixify sends it too.
  • Dashboard extra filters don't inherit the chart's marker.

Compatibility:

  • Tables and unversioned semantic views behave as before.
  • Older selections without a current marker fall back to manual entry, which is the current behavior. Users can reset and reselect fields to get suggestions back.
  • Rolling deploys are safe in both directions: an old frontend sends no version, and an old backend ignores it. Either way the result is manual entry.
  • No migration and no change to persisted shape.

UPDATING.md, the semantic member selections docs and the OpenAPI spec are updated.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Not captured. Before: the filter value picker and Matrixify value list on a versioned semantic view always showed "enter values manually". After: they load suggestions once fields have been explicitly reselected; selections that haven't been reselected still show the manual-entry guidance.

TESTING INSTRUCTIONS

Automated:

pytest tests/unit_tests/semantic_layers/values_endpoint_test.py \
       tests/unit_tests/semantic_layers/selection_identity_test.py
cd superset-frontend && npm run test -- \
  src/explore/components/controls/DndColumnSelectControl/DndFilterSelect.test.tsx \
  src/explore/components/controls/FilterControl/AdhocFilterEditPopoverSimpleTabContent/AdhocFilterEditPopoverSimpleTabContent.test.tsx \
  src/explore/components/controls/MatrixifyDimensionControl.test.tsx

The backend tests include a collision fixture: a legacy title that equals another member's current ID never reaches the cache or provider without a matching version. They also cover cache partitioning by version. The frontend tests check that each control sends the chart's marker, and only that marker, for missing, stale and current versions, using the real control mapper. They also cover a late failing response racing a newer success.

Manual, with a semantic layer whose views report a selection identity version:

  1. Open an existing chart on a versioned semantic view that was saved before its fields were reselected. Add or edit a filter. The value picker offers manual entry only.
  2. Click Start field selection, reselect the fields, and edit the filter again. Suggested values load, and search works.
  3. In Matrixify, Members and alphabetically sorted All modes load values after reselection.
  4. Table-backed charts are unchanged.

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

Follows #44370. The new API surface is an optional query parameter on an existing endpoint.

🤖 Generated with Claude Code

@mikebridge

Copy link
Copy Markdown
Member Author

@aminghadersohi @rebenitez1802 could you take a look when you have a chance? This restores filter-value suggestions on versioned semantic views, gated on the chart's own selection version. It's the follow-up to #44370.

@github-actions github-actions Bot added api Related to the REST API 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 f0a2312
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6accfc1414cff428157d903b
😎 Deploy Preview https://deploy-preview-45109--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.

@codecov

codecov Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.97%. Comparing base (cd526f9) to head (f0a2312).

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #45109      +/-   ##
==========================================
+ Coverage   82.94%   82.97%   +0.03%     
==========================================
  Files        3023     3026       +3     
  Lines      195600   195810     +210     
  Branches    45600    45708     +108     
==========================================
+ Hits       162241   162477     +236     
+ Misses      30148    30122      -26     
  Partials     3211     3211              
Flag Coverage Δ
hive 34.84% <0.00%> (-0.01%) ⬇️
javascript 78.69% <100.00%> (+0.07%) ⬆️
mysql 52.94% <50.00%> (-0.01%) ⬇️
postgres 52.95% <50.00%> (-0.01%) ⬇️
presto 36.63% <0.00%> (-0.01%) ⬇️
python 86.57% <100.00%> (+<0.01%) ⬆️
sqlite 52.70% <50.00%> (-0.01%) ⬇️
unit 80.41% <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.

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

Read through the backend gate, cache keying, and the frontend plumbing. Looks sound overall; a few notes, none blocking.

  1. superset/datasource/api.py: the gate is a plain equality check of a client-supplied value against the view's current selection_identity_version. That is fine for stopping the stale-title collision described in the summary, but it means the marker is an assertion by the caller, not proof. A hand-built request, or any caller that copies the version from datasource metadata, passes the gate. If that is accepted (suggestions are not a security boundary, and authorization is checked before this), the docstring and UPDATING note could say so explicitly so nobody later treats it as a trust check.

  2. Chart-level marker vs per-filter provenance: form_data.semantic_selection_version applies to the whole chart. A chart that is reselected, saved, and later has its semantic view's version bumped just falls back to manual entry, which is the intended direction. But a filter column added by hand-editing the saved form data would still pass. Probably out of scope, but worth a line in the docs.

  3. AdhocFilterEditPopoverSimpleTabContent/index.tsx: adding selectionVersion/datasourceType/datasourceId to the key of SelectWithLabel remounts the select when they change. That is right for clearing stale options, but it also drops any in-progress typed text if the version changes while the popover is open. Rare, so just confirming it is intended.

  4. MatrixifyDimensionControl.tsx: the signal.aborted guards in catch/finally are a good fix but go beyond the PR's stated scope; the test covering the late-failure race is the right companion. Please confirm the "loading" state cannot stick when an aborted request is the last one issued (the next effect run sets it again, so it looks fine).

  5. Tests: backend coverage is good (missing/stale/current version, cached and uncached, and cache-key separation). I could not find a case asserting that the cache key for tables and unversioned views is byte-identical to before; since the summary promises that, a small assertion on the key (or a pinned expected hash) would guard against accidental invalidation of existing caches. On the frontend, a test for the isExtra branch (dashboard extra filters send no marker) would back the claim in the summary.

  6. Minor: the controls.tsx mapper reads state.form_data?.semantic_selection_version; other consumers of this mapper that pass no form_data get undefined, which degrades to manual entry. Fine, just noting it is silent.

@mikebridge
mikebridge marked this pull request as ready for review October 9, 2026 04:37
@codeant-ai-for-open-source

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

Copy link
Copy Markdown
Contributor

CodeAnt PR Risk: Low Risk

  • The PR appears safe to merge; filter and Matrixify suggestions use the selection version, which the API checks before cache or provider access.
  • Added tests cover missing, stale, and matching versions, cache separation, and late filter suggestions.

Assessed commit: f0a2312ec9c2

mikebridge and others added 2 commits October 8, 2026 23:17
…ersioned cache keys

Reset the Matrixify values spinner at the start of each effect run, so an
aborted load followed by an early return no longer leaves it loading. Pin
that unversioned views keep their pre-marker column-values cache material,
and document that the selection marker is a per-chart caller assertion, not
an authorization or per-filter provenance check.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@pull-request-size pull-request-size Bot added size/XL and removed size/L labels Oct 9, 2026
@mikebridge

Copy link
Copy Markdown
Member Author

Thanks @aminghadersohi, this was a careful read. Changes are in 77d82cd.

  1. The marker is an assertion, not proof. Agreed. UPDATING already calls it "a compatibility contract, not an authorization credential". I've said the same in the code comment at the gate and in the user docs: anyone can copy the version from datasource metadata, it only prevents stale-title collisions, and authorization is checked before it.
  2. Chart-level marker vs per-filter provenance. Added a docs line: the version is recorded per chart, so a filter column added by hand-editing saved form data inherits it. Suggestions are a usability aid for compatible selections, not a per-filter provenance guarantee.
  3. Remount drops typed text. Intended. The key changes only on reselection or a datasource change, and clearing the previous generation's options matters more there than keeping half-typed text.
  4. Can loading stick? In one narrow case, yes. An in-flight load aborted by a change that keeps the values select visible but takes an early return (switching to a datasource with filter_select: false) skipped its own reset. I fixed it by resetting loading at the start of each effect run. The new test fails without the fix.
  5. Test coverage.
    • Cache key: test_unversioned_suggestion_cache_material_is_unchanged asserts that an unversioned view's key material keeps exactly the previous five fields, even when a marker is sent. Together with the existing legacy-bytes test of _column_values_cache_key, that pins the key end to end. Tables take the same path with no selection version.
    • isExtra: already covered. The test.each case ['cube-member-id-v1', true] in AdhocFilterEditPopoverSimpleTabContent.test.tsx expects no marker for dashboard extra filters.
  6. Silent undefined. Agreed it's silent. It degrades to manual entry, which is the safe direction, so I've left it as is.

@github-actions github-actions Bot added the requires:rebase Requires rebasing on top of current master label Oct 11, 2026
@github-actions github-actions Bot removed the requires:rebase Requires rebasing on top of current master label Oct 12, 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.

Approving at f0a2312. I checked that raise_for_access runs before the selection-version gate, and that the gate runs before the cache key, the cache read and values_for_column. Missing, stale and empty markers return the unavailable status. The unversioned and table key material is pinned by test_unversioned_suggestion_cache_material_is_unchanged. All six points from my earlier review are addressed: the gate comment and docs state that the marker is not a credential, the chart-level marker caveat is documented, the Matrixify loading reset is in (its test fails when the reset line is removed), and the isExtra case is covered. Locally the semantic_layers and datasource unit suites pass, apart from one failure caused by my environment, as do the three changed jest suites (101 tests). CI is green.

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

Labels

api Related to the REST API doc Namespace | Anything related to documentation packages size/XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants