You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "betodealmeida (via GitHub)" <gi...@apache.org> on 2026/05/20 00:46:06 UTC

[PR] feat(semantic layers): form for SL with a single semantic [superset]

betodealmeida opened a new pull request, #40280:
URL: https://github.com/apache/superset/pull/40280

   <!---
   Please write the PR title following the conventions at https://www.conventionalcommits.org/en/v1.0.0/
   Example:
   fix(dashboard): load charts correctly
   -->
   
   ### SUMMARY
   <!--- Describe the change below, including rationale and design decisions -->
   
   Adds two pieces of UX plumbing so semantic-layer extensions can ship a runtime form that fully describes a single view (think MetricFlow cubes), and so any runtime form that exposes a "pick several from a fixed list" field renders the right control.
   
   #### Changes
   
   ##### `superset-frontend/src/features/semanticLayers/jsonFormsHelpers.tsx`
   
   New JSON Forms renderer `MultiEnumControl` for schemas of the shape:
   
   ```json
   { "type": "array", "items": { "enum": [...], "x-enumNames": [...] } }
   ```
   
   - Rendered as a single Antd `<Select mode="multiple">` (tag-style multi-pick).
   - Uses `items.x-enumNames` for display labels, falling back to the raw enum value.
   - Honors the host form's `config.refreshingSchema` flag: the control shows a loading indicator while the schema is being re-fetched (e.g. dependent options narrowing as the user picks), without becoming disabled.
   - Registered at rank `35` so it beats upstream `PrimitiveArrayControl` (rank `30`), which previously rendered a misleading "Add …" repeater of single selects that couldn't surface `x-enumNames`.
   - The existing `enumNamesEntry` (scalar `x-enumNames` renderer) is narrowed to only fire when `schema.type !== 'array'`, so the new array entry owns the multi-select case.
   
   ##### `superset-frontend/src/features/semanticViews/AddSemanticViewModal.tsx`
   
   Adds support for a top-level `x-singleView: true` flag on a layer's runtime schema. When set, the layer is treated as describing exactly one semantic view:
   
   - The "Semantic Views" multi-select picker is hidden.
   - Once `get_semantic_views` returns, the first not-yet-added view is auto-selected so the **Add** button can fire without an extra click.
   - The selection effect is idempotent (compares previous and next arrays before calling `setSelectedViewNames`), so it doesn't re-render the modal in a loop.
   
   Also fixes a small bug in the "no runtime config" path of the layer-selection effect: previously, when a layer's runtime schema had no `properties` we skipped `applyRuntimeSchema(schema)` and went straight to `fetchViews`, which threw away top-level metadata like `x-singleView`. We now call `applyRuntimeSchema(schema)` first, then fetch views.
   
   #### Why this matters
   
   Extensions like MetricFlow expose layers that *are* a single cube — there is no list of views to pick from. Before this branch, the modal forced the user through an empty-but-required picker. With `x-singleView`, the runtime form fully drives the Add flow.
   
   `MultiEnumControl` is a generic prerequisite: those same single-view runtime schemas commonly include "select N tags / N dimensions" array-of-enum fields, and the upstream PrimitiveArray renderer wasn't usable for them.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   <!--- Skip this if not applicable -->
   
   ### TESTING INSTRUCTIONS
   <!--- Required! What steps can be taken to manually verify the changes? -->
   
   - Open *Add Semantic View* against a layer **without** `x-singleView`: behavior unchanged — picker is shown, manual selection required.
   - Open *Add Semantic View* against a layer **with** `x-singleView: true` and a non-empty runtime form: picker is hidden; once `get_semantic_views` resolves, the first available view is preselected and **Add** is enabled.
   - Same as above but the runtime form has *no* `properties`: `x-singleView` is still honored (picker hidden, view auto-selected).
   - A runtime form with an `array`/`items.enum` field renders an Antd tag-style multi-select using `x-enumNames` for labels; the control shows a loading spinner during schema refresh without disabling editing.
   
   ### ADDITIONAL INFORMATION
   <!--- Check any relevant boxes with "x" -->
   <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] 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
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(semantic layers): form for SL with a single semantic [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #40280:
URL: https://github.com/apache/superset/pull/40280#issuecomment-4505833088

   AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
   
   <details>
   <summary>
   Bito Usage Guide
   </summary>
   
   **Commands**
         
   Type the following command in the pull request comment and save the comment.
         
   - `/review` - Manually triggers a full AI review.
   
   - `/pause` - Pauses automatic reviews on this pull request.
   - `/resume` - Resumes automatic reviews.
   - `/resolve` - Marks all Bito-posted review comments as resolved.
   - `/abort` - Cancels all in-progress reviews.
   
         
   Refer to the <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/available-commands" target="_blank" rel="noopener noreferrer">documentation</a> for additional commands.
         
   **Configuration**
   
   This repository uses `Superset` You can customize the agent settings <a href="https://alpha.bito.ai/home/ai-agents/code-review-agent" target="_blank" rel="noopener noreferrer">here</a> or contact your Bito workspace admin at evan@preset.io.
         
   **Documentation & Help**
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/getting-started/install-run-using-bito-cloud/create-or-customize-an-agent-instance" target="_blank" rel="noopener noreferrer">Customize agent settings</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/implementing-custom-code-review-rules" target="_blank" rel="noopener noreferrer">Review rules</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent" target="_blank" rel="noopener noreferrer">General documentation</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/faqs" target="_blank" rel="noopener noreferrer">FAQ</a>
   
   </details>
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(semantic layers): form for SL with a single SV [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #40280:
URL: https://github.com/apache/superset/pull/40280#issuecomment-4523947828

   **Bito Automatic Review Skipped – PR Already Merged**<br/><br/>Bito scheduled an automatic review for this pull request, but the review was skipped because this PR was merged before the review could be run.<br/>No action is needed if you didn't intend to review it. To get a review, you can type `/review` in a comment and save it


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(semantic layers): form for SL with a single SV [superset]

Posted by "betodealmeida (via GitHub)" <gi...@apache.org>.
betodealmeida merged PR #40280:
URL: https://github.com/apache/superset/pull/40280


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(semantic layers): form for SL with a single semantic [superset]

Posted by "netlify[bot] (via GitHub)" <gi...@apache.org>.
netlify[bot] commented on PR #40280:
URL: https://github.com/apache/superset/pull/40280#issuecomment-4493489674

   ### <span aria-hidden="true">✅</span> Deploy Preview for *superset-docs-preview* ready!
   
   
   |  Name | Link |
   |:-:|------------------------|
   |<span aria-hidden="true">🔨</span> Latest commit | 137c9fca6da5f3571d980f6423c9ee11c50bf20b |
   |<span aria-hidden="true">🔍</span> Latest deploy log | https://app.netlify.com/projects/superset-docs-preview/deploys/6a0d044f9910a20008fe4ff6 |
   |<span aria-hidden="true">😎</span> Deploy Preview | [https://deploy-preview-40280--superset-docs-preview.netlify.app](https://deploy-preview-40280--superset-docs-preview.netlify.app) |
   |<span aria-hidden="true">📱</span> Preview on mobile | <details><summary> Toggle QR Code... </summary><br /><br />![QR Code](https://app.netlify.com/qr-code/eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1cmwiOiJodHRwczovL2RlcGxveS1wcmV2aWV3LTQwMjgwLS1zdXBlcnNldC1kb2NzLXByZXZpZXcubmV0bGlmeS5hcHAifQ.30HHLMhyLX7RS55jUqzPvvBllS69aueOYANY5uQx0nU)<br /><br />_Use your smartphone camera to open QR code link._</details> |
   |<span aria-hidden="true">🤖</span> Make changes | [Run an agent on this branch](https://app.netlify.com/projects/superset-docs-preview/agent-runs#q1YqKMrPLShRslJS0lFKKkrMS84Asosz89JzUnWLy4CCKakFOfmVnilAYbNEgxQDE5M0S0tDg0QjAwMDi7RUk7Q0M6VaAA) |
   ---
   <!-- [superset-docs-preview Preview](https://deploy-preview-40280--superset-docs-preview.netlify.app) -->
   _To edit notification comments on pull requests, go to your [Netlify project configuration](https://app.netlify.com/projects/superset-docs-preview/configuration/notifications#deploy-notifications)._


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(semantic layers): form for SL with a single semantic [superset]

Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #40280:
URL: https://github.com/apache/superset/pull/40280#issuecomment-4493572233

   ## [Codecov](https://app.codecov.io/gh/apache/superset/pull/40280?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :x: Patch coverage is `17.07317%` with `34 lines` in your changes missing coverage. Please review.
   :white_check_mark: Project coverage is 64.14%. Comparing base ([`64dae07`](https://app.codecov.io/gh/apache/superset/commit/64dae07675ed840e7a2818b720e1fc4f04b65e43?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`137c9fc`](https://app.codecov.io/gh/apache/superset/commit/137c9fca6da5f3571d980f6423c9ee11c50bf20b?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   :warning: Report is 89 commits behind head on master.
   
   | [Files with missing lines](https://app.codecov.io/gh/apache/superset/pull/40280?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
   |---|---|---|
   | [...d/src/features/semanticLayers/jsonFormsHelpers.tsx](https://app.codecov.io/gh/apache/superset/pull/40280?src=pr&el=tree&filepath=superset-frontend%2Fsrc%2Ffeatures%2FsemanticLayers%2FjsonFormsHelpers.tsx&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2ZlYXR1cmVzL3NlbWFudGljTGF5ZXJzL2pzb25Gb3Jtc0hlbHBlcnMudHN4) | 7.69% | [24 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/40280?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [...rc/features/semanticViews/AddSemanticViewModal.tsx](https://app.codecov.io/gh/apache/superset/pull/40280?src=pr&el=tree&filepath=superset-frontend%2Fsrc%2Ffeatures%2FsemanticViews%2FAddSemanticViewModal.tsx&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2ZlYXR1cmVzL3NlbWFudGljVmlld3MvQWRkU2VtYW50aWNWaWV3TW9kYWwudHN4) | 33.33% | [10 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/40280?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@            Coverage Diff             @@
   ##           master   #40280      +/-   ##
   ==========================================
   - Coverage   64.14%   64.14%   -0.01%     
   ==========================================
     Files        2590     2590              
     Lines      138084   138122      +38     
     Branches    32037    32052      +15     
   ==========================================
   + Hits        88578    88594      +16     
   - Misses      47985    48007      +22     
     Partials     1521     1521              
   ```
   
   | [Flag](https://app.codecov.io/gh/apache/superset/pull/40280/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [javascript](https://app.codecov.io/gh/apache/superset/pull/40280/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `66.99% <17.07%> (-0.02%)` | :arrow_down: |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
   </details>
   
   [:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/superset/pull/40280?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   - :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(semantic layers): form for SL with a single semantic [superset]

Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #40280:
URL: https://github.com/apache/superset/pull/40280#discussion_r3275597937


##########
superset-frontend/src/features/semanticViews/AddSemanticViewModal.tsx:
##########
@@ -254,7 +254,9 @@ export default function AddSemanticViewModal({
           !schema?.properties ||
           Object.keys(schema.properties).length === 0
         ) {
-          // No runtime config needed — fetch views right away
+          // Preserve top-level runtime metadata (e.g. x-singleView) even when
+          // there are no form fields, then fetch views right away.
+          applyRuntimeSchema(schema);

Review Comment:
   **Suggestion:** `schema` is treated as optional in the condition (`!schema?.properties`), but then it is passed directly to `applyRuntimeSchema`. If the API returns `null`/`undefined` for `json.result`, `sanitizeSchema` will dereference `schema.properties` and crash. Add a null guard before calling `applyRuntimeSchema`, and only apply when a real schema object is present. [null pointer]
   
   <details>
   <summary><b>Severity Level:</b> Critical 🚨</summary>
   
   ```mdx
   - ❌ Add Semantic View modal crashes on null runtime schemas.
   - ⚠️ Semantic layer plugins returning null schemas become unusable.
   ```
   </details>
   <details>
   <summary><b>Steps of Reproduction ✅ </b></summary>
   
   ```mdx
   1. Open the Dataset List page, which mounts `AddSemanticViewModal` via
   `<AddSemanticViewModal />` in `superset-frontend/src/pages/DatasetList/index.tsx` (around
   the block shown at lines 1468–1480 in the tool output).
   
   2. In the modal implementation `AddSemanticViewModal`
   (`superset-frontend/src/features/semanticViews/AddSemanticViewModal.tsx`), select a
   semantic layer in the "Semantic Layer" `<Select>`; this triggers `handleLayerChange`
   (useCallback starting around lines 88–120 in the tool output), which calls
   `SupersetClient.post` to `POST /api/v1/semantic_layer/<uuid>/schema/runtime` (lines
   108–110).
   
   3. On the backend, the `runtime_schema` view in `superset/semantic_layers/api.py` (lines
   669–676) calls `cls.get_runtime_schema(...)` and returns its result as
   `payload["result"]`. Configure or implement a semantic layer extension whose
   `get_runtime_schema` returns `None`/`null` instead of a JSON dict (violating but not
   enforced by the abstract contract at
   `superset-core/src/superset_core/semantic_layers/layer.py:80-88`).
   
   4. With `json.result` now `null`, `handleLayerChange` assigns `const schema =
   json.result;` and the condition `if (!schema?.properties ||
   Object.keys(schema.properties).length === 0)` (lines 113–117) evaluates truthy. In this
   branch it calls `applyRuntimeSchema(schema);` at diff line 259. `applyRuntimeSchema`
   (lines 64–69) immediately calls `sanitizeSchema(rawSchema)` from
   `superset-frontend/src/features/semanticLayers/jsonFormsHelpers.tsx` (lines 8–25), which
   dereferences `schema.properties` without a null check. Because `schema` is `null`, this
   causes a runtime TypeError/exception, crashing the Add Semantic View modal whenever a
   misbehaving or future extension returns a null runtime schema.
   ```
   </details>
   
   [Fix in Cursor](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=85c46f45ea834020a14b3a970d19a960&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) | [Fix in VSCode Claude](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=85c46f45ea834020a14b3a970d19a960&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset-frontend/src/features/semanticViews/AddSemanticViewModal.tsx
   **Line:** 259:259
   **Comment:**
   	*Null Pointer: `schema` is treated as optional in the condition (`!schema?.properties`), but then it is passed directly to `applyRuntimeSchema`. If the API returns `null`/`undefined` for `json.result`, `sanitizeSchema` will dereference `schema.properties` and crash. Add a null guard before calling `applyRuntimeSchema`, and only apply when a real schema object is present.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
   Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F40280&comment_hash=e38098ee77923bb500bc99408f080d81b059ffa9a1b178bc458bed8b3dbb6fad&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F40280&comment_hash=e38098ee77923bb500bc99408f080d81b059ffa9a1b178bc458bed8b3dbb6fad&reaction=dislike'>👎</a>



##########
superset-frontend/src/features/semanticViews/AddSemanticViewModal.tsx:
##########
@@ -456,6 +458,32 @@ export default function AddSemanticViewModal({
   const viewsDisabled =
     loadingViews || (!loadingViews && availableViews.length === 0);
 
+  // When ``x-singleView: true`` the runtime form fully describes a single
+  // semantic view (e.g. a MetricFlow cube).  Hide the picker and auto-select
+  // whatever ``get_semantic_views`` returned so the Add button can fire
+  // without an extra user click.
+  const singleViewMode =
+    (runtimeSchema as Record<string, unknown> | null)?.['x-singleView'] ===
+    true;
+
+  useEffect(() => {
+    if (!singleViewMode) return;
+    const namesToAdd = availableViews
+      .filter(v => !v.already_added)
+      .map(v => v.name)
+      .sort((a, b) => a.localeCompare(b))
+      .slice(0, 1);

Review Comment:
   **Suggestion:** Auto-selection in single-view mode sorts names alphabetically before picking one, which can select a different view than the backend-provided first candidate. This contradicts the intended "first returned not-yet-added view" behavior and can add the wrong semantic view; remove the sort and pick the first eligible item in API order. [logic error]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ❌ Wrong semantic view auto-selected in single-view runtime mode.
   - ⚠️ Users may add unintended views, causing configuration mistakes.
   ```
   </details>
   <details>
   <summary><b>Steps of Reproduction ✅ </b></summary>
   
   ```mdx
   1. Implement or configure a semantic layer backend whose `get_runtime_schema` adds a
   top-level `"x-singleView": true` flag to its runtime schema (contract defined at
   `superset-core/src/superset_core/semantic_layers/layer.py:80-88`, and returned via
   `runtime_schema` in `superset/semantic_layers/api.py:669-676`). In the frontend, this
   schema is stored as `runtimeSchema` in `AddSemanticViewModal` and used to compute
   `singleViewMode` at diff lines 465–468.
   
   2. From the Dataset List page (`superset-frontend/src/pages/DatasetList/index.tsx`), open
   `AddSemanticViewModal` for that layer and select the semantic layer in the "Semantic
   Layer" `<Select>`. `handleLayerChange` in `AddSemanticViewModal.tsx` (lines 88–120)
   fetches the runtime schema and, when there are no runtime fields, calls `fetchViews(uuid,
   {}, gen);` directly after `applyRuntimeSchema` (diff lines 259–261). `fetchViews` (lines
   42–53) posts to `POST /api/v1/semantic_layer/<uuid>/views` and sets `availableViews` from
   `json.result`.
   
   3. On the backend, `views` in `superset/semantic_layers/api.py` (lines 60–62, 75–80)
   delegates to `layer.implementation.get_semantic_views(runtime_data)` and returns the
   results in order. The unit test `test_views` at
   `superset/tests/unit_tests/semantic_layers/api_test.py:1920-33` asserts that the first
   element of the JSON response preserves backend order (`result[0]["name"] == "View A"`).
   Configure a backend implementation whose `get_semantic_views` returns multiple
   not-yet-added views in a deliberate order that is not alphabetical (e.g., `["Primary
   View", "Alternate View"]` where the first element is the intended default).
   
   4. Once `availableViews` is populated and `singleViewMode` is true, the `useEffect`
   introduced at diff lines 469–475 runs. It computes `namesToAdd` as:
   
      ```ts
   
      const namesToAdd = availableViews
   
        .filter(v => !v.already_added)
   
        .map(v => v.name)
   
        .sort((a, b) => a.localeCompare(b))
   
        .slice(0, 1);
   
      ```
   
      This sorts by `v.name` before taking the first element, so the lexicographically
      smallest name is chosen instead of the first backend-provided candidate.
      `setSelectedViewNames` then stores this sorted-first name. When the user clicks
      **Add**, `handleSave` (lines 195–205) filters `availableViews` by `selectedViewNames`
      and posts them to `/api/v1/semantic_view/`, causing the wrong semantic view
      (alphabetically first, not the backend's first candidate) to be created in single-view
      mode.
   ```
   </details>
   
   [Fix in Cursor](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=5c87120e7c7e4381acaf592672461e56&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) | [Fix in VSCode Claude](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=5c87120e7c7e4381acaf592672461e56&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset-frontend/src/features/semanticViews/AddSemanticViewModal.tsx
   **Line:** 471:475
   **Comment:**
   	*Logic Error: Auto-selection in single-view mode sorts names alphabetically before picking one, which can select a different view than the backend-provided first candidate. This contradicts the intended "first returned not-yet-added view" behavior and can add the wrong semantic view; remove the sort and pick the first eligible item in API order.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
   Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F40280&comment_hash=97bf60e7c34e75f9c0132178b5f73aef24d9c2433b5f447bb1085dffe334c42d&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F40280&comment_hash=97bf60e7c34e75f9c0132178b5f73aef24d9c2433b5f447bb1085dffe334c42d&reaction=dislike'>👎</a>



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(semantic layers): form for SL with a single semantic [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on code in PR #40280:
URL: https://github.com/apache/superset/pull/40280#discussion_r3279535875


##########
superset-frontend/src/features/semanticLayers/jsonFormsHelpers.tsx:
##########
@@ -255,14 +255,98 @@ const EnumNamesRenderer = withJsonFormsControlProps(EnumNamesControl);
 const enumNamesEntry = {
   // Rank 5: higher than the default string renderer (2–3) so this fires
   // whenever x-enumNames is present, regardless of the underlying type.
+  // Array-of-enum schemas are handled by ``multiEnumEntry`` below — this
+  // renderer only targets scalar string/number controls.
   tester: rankWith(
     5,
+    and(
+      schemaMatches(s => {
+        const names = (s as Record<string, unknown>)['x-enumNames'];
+        return Array.isArray(names) && (names as unknown[]).length > 0;
+      }),
+      schemaMatches(
+        s => (s as Record<string, unknown>)?.type !== 'array',
+      ),
+    ),
+  ),
+  renderer: EnumNamesRenderer,
+};
+
+/**
+ * Renderer for ``{type: 'array', items: {enum: [...]}}`` schemas.  Renders
+ * a single Antd Select with ``mode="multiple"`` (tag-style multi-select),
+ * matching the natural expectation of a "pick several from a list" control.
+ *
+ * Without this, the default ``PrimitiveArrayControl`` from the upstream
+ * library renders an "Add …" button that creates one single-select per
+ * element — visually wrong for an enum multi-select and unable to display
+ * ``items.x-enumNames`` labels.
+ *
+ * The renderer is dynamic-aware: when the host form is refreshing the
+ * schema (e.g. compatible options narrowing as the user picks), the Select
+ * shows a loading indicator without becoming disabled, so the user can
+ * continue editing while options refresh.
+ */
+function MultiEnumControl(props: ControlProps) {
+  const { refreshingSchema } = props.config ?? {};
+  const arraySchema = props.schema as Record<string, unknown>;
+  const itemsSchema =
+    (arraySchema.items as Record<string, unknown>) ??
+    ({} as Record<string, unknown>);
+
+  const enumValues = (itemsSchema.enum as unknown[]) ?? [];
+  const enumNames =
+    (itemsSchema['x-enumNames'] as string[]) ?? enumValues.map(String);
+
+  const options = enumValues.map((value, index) => ({
+    value: value as string | number,
+    label: enumNames[index] ?? String(value),
+  }));
+
+  const value = Array.isArray(props.data) ? (props.data as unknown[]) : [];
+
+  const tooltip = (props.uischema?.options as Record<string, unknown>)
+    ?.tooltip as string | undefined;
+
+  return (
+    <Form.Item label={props.label} tooltip={tooltip}>
+      <Select
+        mode="multiple"
+        value={value as (string | number)[]}
+        onChange={next => props.handleChange(props.path, next)}
+        options={options}
+        style={{ width: '100%' }}
+        disabled={!props.enabled}
+        loading={!!refreshingSchema}
+        allowClear
+        optionFilterProp="label"
+        placeholder={
+          (props.uischema?.options as Record<string, unknown>)
+            ?.placeholderText as string | undefined
+        }
+      />
+    </Form.Item>
+  );
+}

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Missing unit tests for MultiEnumControl</b></div>
   <div id="fix">
   
   The new MultiEnumControl renderer and multiEnumEntry tester lack test coverage. Per BITO.md rule [6262], tests should verify actual behavior logic. Add tests to validate the multi-select rendering, enum label mapping, and schema matching logic.
   </div>
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #9c60cb</i></small>
   </div>
   
   ---
   Should Bito avoid suggestions like this for future reviews? (<a href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
   - [ ] Yes, avoid them



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(semantic layers): form for SL with a single semantic [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #40280:
URL: https://github.com/apache/superset/pull/40280#issuecomment-4493475197

   AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org