Skip to content

feat(semantic-layer): allow toggling SEMANTIC_LAYERS at runtime - #45061

Merged
aminghadersohi merged 15 commits into
apache:masterfrom
mikebridge:sc-123832-runtime-semantic-layers-gate
Oct 13, 2026
Merged

aminghadersohi merged 15 commits into
apache:masterfrom
mikebridge:sc-123832-runtime-semantic-layers-gate

Conversation

@mikebridge

Copy link
Copy Markdown
Member

SUMMARY

SEMANTIC_LAYERS could previously only be decided at boot. It can now be toggled at runtime: the flag is evaluated per request through the feature-flag hook (IS_FEATURE_ENABLED_FUNC), and the semantic-layer APIs are registered on every startup.

When the flag is off, every entry point that reads semantic data refuses with "Semantic layers are not enabled." before any data access: chart data, dashboards, Explore, form-data and permalinks, the datasource API, async queries, cache warm-up, dashboard screenshots and thumbnails, and the MCP view tools. Existing role and object permissions still apply when it is on.

  • SQL datasets are unaffected, as are the dataset paths of MCP tools that accept either a dataset or a semantic view. Unscoped MCP metric listings omit semantic views while the flag is off.
  • With the flag on, behavior is unchanged.
  • Stored assets are left intact. Dashboard dataset responses omit semantic views, chart saves reject semantic sources, and legacy batch warm-up records a per-chart unavailable error and continues.
  • Dashboard images that contain a semantic chart are refused (404) while the flag is off, whether freshly rendered or cached, because a cached image cannot encode the flag. This is documented in UPDATING.md and the feature-flags docs.
  • ENABLE_EXTENSIONS remains the deployment prerequisite for provider extensions. During a rolling upgrade, enable the flag at runtime only after all web and worker processes carry these guards.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

No visual redesign. Existing chart error rendering displays "Semantic layers are not enabled." while semantic datasource metadata is unavailable.

TESTING INSTRUCTIONS

  1. Initialize the app and permissions with SEMANTIC_LAYERS=False. Verify semantic API routes return 404 and that both API classes and their permission-view pairs are registered.
  2. Through an IS_FEATURE_ENABLED_FUNC hook, toggle the semantic flag on, off, then on without restarting. Verify normal behavior resumes when enabled, and that while disabled queries, warm-up, metadata, cached images and semantic MCP tools refuse access. Ordinary dataset queries continue to work.
  3. With an existing semantic chart and dashboard, verify chart metadata remains listed, dashboard datasets omit semantic entries, and chart create and title-only update are refused while disabled. Stored assets must remain unchanged.
  4. Run pytest tests/integration_tests/semantic_layers/api_flag_test.py against an initialized test metadata DB, pytest tests/unit_tests/semantic_layers, and the focused chart, async-worker and MCP unit tests. Run Jest for src/components/Chart/Chart.test.tsx.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags: SEMANTIC_LAYERS
  • Changes UI: runtime menu labels and existing unavailable-state rendering
  • 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: runtime availability; existing API routes are always registered
  • Removes existing feature or API

🤖 Generated with Claude Code

@github-actions github-actions Bot added api Related to the REST API doc Namespace | Anything related to documentation labels Oct 7, 2026
@mikebridge
mikebridge marked this pull request as ready for review October 7, 2026 19:56
@netlify

netlify Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for superset-docs-preview ready!

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

Comment thread superset/semantic_layers/api.py Resolved
@codeant-ai-for-open-source

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

Copy link
Copy Markdown
Contributor

CodeAnt PR Risk: Low Risk

  • The PR appears safe to merge; no concrete blocking issue is evident in the current changes or review conversation.
  • Runtime availability checks cover semantic APIs, queries, chart saves, images, dashboard metadata, and MCP tools, with tests for disabled and enabled behavior.
  • The reported concern about the API response call is contradicted by the route tests, which verify the disabled routes return 404.

Assessed commit: 16beecffccb3

@codecov

codecov Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.13889% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.07%. Comparing base (a26c984) to head (16beecf).

Files with missing lines Patch % Lines
superset/explore/form_data/api.py 40.00% 3 Missing ⚠️
superset/charts/api.py 75.00% 0 Missing and 2 partials ⚠️
superset/explore/permalink/api.py 66.66% 1 Missing ⚠️
superset/mcp_service/chart/tool/list_charts.py 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           master   #45061       +/-   ##
===========================================
+ Coverage   56.04%   83.07%   +27.03%     
===========================================
  Files        3027     3028        +1     
  Lines      196347   196462      +115     
  Branches    45855    45876       +21     
===========================================
+ Hits       110038   163220    +53182     
+ Misses      85257    30017    -55240     
- Partials     1052     3225     +2173     
Flag Coverage Δ
hive 35.08% <36.11%> (+0.31%) ⬆️
javascript 78.73% <ø> (ø)
mysql 53.25% <67.36%> (?)
postgres 53.25% <67.36%> (?)
presto 36.86% <36.11%> (+0.30%) ⬆️
python 86.69% <92.36%> (+50.10%) ⬆️
sqlite 53.01% <67.36%> (?)
unit 80.56% <81.94%> (?)

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.

@gabotorresruiz
gabotorresruiz self-requested a review October 7, 2026 20:54

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

No blocking findings; CI is green and two non-blocking inline notes are below. The codeant TypeError thread on semantic_layers/api.py:92 is a false positive: BaseApi.response is a staticmethod, and calling the guard with the flag off returns 404 {"message":"Not found"}.

@github-actions github-actions Bot added the requires:rebase Requires rebasing on top of current master label Oct 8, 2026
Mike Bridge added 2 commits October 8, 2026 09:34
…emantic-layers-gate

# Conflicts:
#	UPDATING.md
Address review r4215043471 by asserting disabled semantic datasets do not count as inaccessible. Document the bootstrap cache delay noted in r4215043488.

@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 628687f: the MCP dashboard test now fails if the semantic-view skip is removed, the bootstrap-cache delay is documented, and CI is green.

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

Copy link
Copy Markdown
Contributor

@mikebridge This now has merge conflicts with master after #45105 merged. Could you merge master? I'll merge once it's green.

Retain both rollout notes and map disabled semantic chart targets to
structured MCP availability responses introduced by master targeting.
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 size/XXL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants