Skip to content

feat(semantic): add metadata sync and cache inspection UI - #44851

Closed
mikebridge wants to merge 132 commits into
apache:masterfrom
mikebridge:sc-121047-metadata-refresh-ui
Closed

mikebridge wants to merge 132 commits into
apache:masterfrom
mikebridge:sc-121047-metadata-refresh-ui

Conversation

@mikebridge

@mikebridge mikebridge commented Oct 1, 2026 •

Copy link
Copy Markdown
Member

Why

When someone adds or changes a metric or dimension in their semantic layer (for example in dbt/MetricFlow), Superset keeps using what it has cached:

  • the list of metrics and dimensions it discovered;
  • which of them can be combined;
  • the results of queries already run.

Today the only way to see the change is to wait for those caches to expire. This stack lets an authorized user clear the semantic-layer caches on demand, with a "Sync metadata" button in the semantic view editor. The new definitions show up right away, and results cached under the old definitions are never served afterwards.

It's split into four PRs so each can be reviewed on its own. Everything is default-off.

PR What it adds
#44834 The interface a semantic-layer provider implements to support refresh (no behaviour change)
#44835 A shared store for the refreshed catalog, with cache keys tied to it so a refresh invalidates compatibility answers and cached query results
#44849 Authorized operations (refresh catalog, clear catalog, clear compatibility answers), with permission checks before any provider call
#44851 (this PR) The "Sync metadata" button in the semantic view editor, and reloading Explore afterwards

SUMMARY

Fourth and last PR in the stack replacing #44808 (semantic-view metadata refresh). Stacked on #44849 → #44835 → #44834; please review only the UI layer's changes. It's default-off.

It adds the user-facing pieces on top of the authorized maintenance operations:

  • Sync metadata in the semantic view editor: a small tertiary button with the database icon in the modal's tab bar, matching the dataset editor's sync action. It's draft-safe: it never saves the view, and it shows request state while syncing.
  • Explore reload after sync: the datasource's metrics and dimensions reload, so a newly added provider metric shows up and is selectable (including for Big Number), without saving the chart. If publication succeeds but the reload fails, the reload can be retried separately.
  • Safe error messages for every refresh error category, plus read-only cache timing diagnostics.

The button is the first caller of a UI-independent operation; other entry points can use the same API later.

The Cache metadata tab is a default-off diagnostic. Browser and live-provider acceptance are still pending.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Screenshot 2026-09-29 at 5 56 56 PM

TESTING INSTRUCTIONS

  • Focused Jest: 95 passed (SemanticViewEditModal, exploreActions, DatasourceControl, DatasetList). Scoped TypeScript checks pass.
  • Manual: enable the semantic-layer metadata refresh configuration, add a metric in the provider, click Sync metadata in the view editor, and confirm the new metric is selectable in Explore and on a Big Number chart.

ADDITIONAL INFORMATION

Includes the one-line CodeQL init v4.38.2 pin (identical to Dependabot #44860) to unbreak the Analyze checks after master bumped analyze. It disappears once #44860 merges.

  • Has associated issue:
  • Required feature flags: default-off configuration
  • Changes UI
  • Includes DB Migration
  • Introduces new feature or API
  • Removes existing feature or API

Stacked on the three PRs above; browser and live-provider acceptance are still pending.

@github-actions github-actions Bot added i18n Namespace | Anything related to localization api Related to the REST API doc Namespace | Anything related to documentation labels Oct 1, 2026
@codecov

codecov Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.59083% with 75 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.75%. Comparing base (001cb57) to head (6d61811).
⚠️ Report is 8 commits behind head on master.

Files with missing lines Patch % Lines
superset/coordination/metadata_resolver.py 64.86% 22 Missing and 4 partials ⚠️
superset/coordination/deadline_backend.py 87.42% 19 Missing and 1 partial ⚠️
...perset/commands/semantic_layer/refresh_metadata.py 96.06% 4 Missing and 3 partials ⚠️
superset/common/query_context_processor.py 88.33% 3 Missing and 4 partials ⚠️
superset/datasource/api.py 81.81% 1 Missing and 3 partials ⚠️
...c/features/semanticViews/SemanticViewEditModal.tsx 98.42% 2 Missing ⚠️
...et/commands/semantic_layer/inspect_query_result.py 91.66% 1 Missing and 1 partial ⚠️
superset/daos/semantic_layer.py 81.81% 2 Missing ⚠️
...vice/semantic_layer/tool/get_compatible_metrics.py 90.00% 1 Missing and 1 partial ⚠️
superset/tasks/async_queries.py 92.00% 1 Missing and 1 partial ⚠️
... and 1 more
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #44851      +/-   ##
==========================================
+ Coverage   82.59%   82.75%   +0.16%     
==========================================
  Files        3005     3019      +14     
  Lines      186941   188529    +1588     
  Branches    43308    43575     +267     
==========================================
+ Hits       154399   156013    +1614     
+ Misses      29778    29736      -42     
- Partials     2764     2780      +16     
Flag Coverage Δ
hive 36.10% <25.71%> (-0.10%) ⬇️
javascript 78.40% <98.87%> (+0.07%) ⬆️
mysql 54.89% <37.90%> (-0.19%) ⬇️
postgres 54.90% <37.90%> (-0.19%) ⬇️
presto 37.94% <27.31%> (-0.11%) ⬇️
python 86.60% <94.98%> (+0.19%) ⬆️
sqlite 54.48% <27.80%> (-0.34%) ⬇️
unit 79.89% <94.77%> (+0.36%) ⬆️

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.

@netlify

netlify Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for superset-docs-preview ready!

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

@@ -188,15 +218,102 @@ export default function SemanticViewEditModal({
});
addSuccessToast?.(t('Semantic view updated'));
onSave();

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.

A slow Save can overwrite a newer sync here. Closing the modal resets busy, so the editor can be reopened and Sync metadata completed while the PUT is still pending. When the PUT then resolves, this unguarded onSave() runs the handleDatasourceSave(datasource) captured at click time and restores the pre-sync datasource and controls in Explore. Should onSave() be skipped (or re-read the current datasource) when isCurrent() is false?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Confirmed. UI commit 6d61811a40 guards onSave with the same operation generation as modal closure, so an old PUT can still report its outcome without replaying a stale Explore datasource callback. The regression starts Save, closes/reopens, completes a newer sync, then resolves Save and verifies no stale callback or modal close and the refreshed structure remains. One side effect: a Save that finishes after the editor has closed no longer refreshes the dataset list, so the list may need a manual reload in that case.

# Later execution retains this view without renewing its budget.
_captured: str | None = source.metadata_cache_token
except (SupersetException, MetadataRefreshError) as ex:
raise QueryObjectValidationError(error_msg_from_exception(ex)) from ex

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.

A MetadataRefreshError raised while preparing a semantic-view annotation is converted to QueryObjectValidationError here, so chart-data returns a validation-style 400 with no category. For example, with metadata storage unavailable the client gets a 400 instead of the 503 unavailable / 502 / 504 mapping that semantic-metadata-operations.md says applies to chart-data requests, so retry handling keyed on the status code won't fire. Should this re-raise the typed error, or should the doc call out this exception?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Confirmed and repaired in owning store commit 34f90b5244, merged into local UI 6d61811a40. Typed metadata errors escape annotation validation conversion and reach the API's existing GET/POST mapper. Processor-plus-adapter regressions demonstrate503/504/502 instead of400, while existing route mapping tests pass; no new live annotation HTTP run is claimed.

@github-actions github-actions Bot removed the requires:rebase Requires rebasing on top of current master label Oct 7, 2026
if not participates(layer):
raise MetadataRefreshError("configuration_changed")
if db.session.new or db.session.dirty or db.session.deleted:
_revalidation_unavailable("pending ORM changes")

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.

A cold async chart query can fail here with unavailable even though PostgreSQL, Redis and the provider are healthy. _execute_task_body commits the PENDING→IN_PROGRESS transition and then assigns task.status = IN_PROGRESS on the expired Task row in the same db.session (scheduler.py:562), so that instance is dirty (or, after the next autoflush, has an assigned transaction ID). When execute_chart_query then needs to publish a catalog because the snapshot expired or was invalidated while the task was queued, before_publish runs this check and reaches _revalidation_unavailable, while warm-catalog reads skip it. The worker test calls .func directly, so it never goes through that bookkeeping. Is the caller-transaction check meant to apply to the GTF task row, or should the worker revalidate through its own connection?

onSave();
onHide();
if (isCurrent()) {
onSave();

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.

Closing the editor mid-Save with no sync now skips onSave, so DatasetList shows the old description after the success toast; master refreshes it. Skipping only when a sync completed after Save started keeps the race fix. No suggestion: it needs a ref set in handleSync too.

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

Copy link
Copy Markdown
Member Author

This stack is being replaced by #45100 (configuration Save bumps a per-layer cache version; no coordinated refresh machinery). Context in #44835 (comment).

@mikebridge

Copy link
Copy Markdown
Member Author

Closing as superseded by #45100, which narrows SC-121047's refresh work to the configuration-edit workflow: saving a semantic layer bumps a per-layer cache version, plus a small Reload metadata action for upstream-only changes, with no coordinated refresh/store machinery. See the context in #44835 (comment). Thanks to everyone who reviewed this stack; several of the lessons and tests carried over.

@mikebridge mikebridge closed this Oct 8, 2026
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 i18n Namespace | Anything related to localization requires:rebase Requires rebasing on top of current master size/XXL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants