codeant-ai-for-open-source[bot] commented on code in PR #43649:
URL: https://github.com/apache/superset/pull/43649#discussion_r3881943351


##########
superset/models/slice.py:
##########
@@ -161,6 +167,24 @@ class Slice(  # pylint: disable=too-many-public-methods
         remote_side="SqlaTable.id",
         lazy="subquery",
     )
+    # Counterpart of ``table`` for charts built on a semantic view. 
``datasource_id``
+    # is only unique within a ``datasource_type``, so the join is guarded on 
the
+    # type to keep a same-id dataset from being resolved by mistake. View-only:
+    # ``datasource_id`` is written by the chart, never through this 
relationship.
+    # ``selectin`` costs one extra bounded ``IN (...)`` query per batch of 
charts
+    # loaded (the type predicate rules out the FK-only shortcut); the default
+    # lazy load would be one query per semantic-view chart on a list page. The
+    # string target resolves because ``superset.daos.datasource`` imports
+    # ``SemanticView`` unconditionally during app initialisation.
+    semantic_view = relationship(
+        "SemanticView",
+        foreign_keys=[datasource_id],
+        primaryjoin="and_(Slice.datasource_id == SemanticView.id, "
+        "Slice.datasource_type == 'semantic_view')",
+        remote_side="SemanticView.id",
+        viewonly=True,
+        lazy="selectin",
+    )

Review Comment:
   **Suggestion:** The new semantic-view relationship is used for display 
resolution, but the chart response schema still serializes `datasource_uuid` 
from the hard-coded `table.uuid` path. Consequently, semantic-view charts now 
expose a name and URLs while returning `datasource_uuid: null`, breaking 
clients that rely on the chart datasource UUID. The response schema needs to 
resolve the UUID through the same type-dispatched display datasource or expose 
the semantic view UUID for semantic-view charts. [api mismatch]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ❌ Semantic-view chart API responses return `datasource_uuid: null`.
   - ⚠️ API clients cannot identify semantic views by UUID.
   - ⚠️ Datasource metadata fields become inconsistent across chart types.
   ```
   </details>
   
   [![Use CodeAnt 
Skill](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/use-codeant-skill-flat-v2.svg)](https://docs.codeant.ai/cli/resolve-pr-comments-skill)
 [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=138b8de2f8c94bc798fe5af400a11216&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=138b8de2f8c94bc798fe5af400a11216&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset/models/slice.py
   **Line:** 179:187
   **Comment:**
        *Api Mismatch: The new semantic-view relationship is used for display 
resolution, but the chart response schema still serializes `datasource_uuid` 
from the hard-coded `table.uuid` path. Consequently, semantic-view charts now 
expose a name and URLs while returning `datasource_uuid: null`, breaking 
clients that rely on the chart datasource UUID. The response schema needs to 
resolve the UUID through the same type-dispatched display datasource or expose 
the semantic view UUID for semantic-view charts.
   
   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%2F43649&comment_hash=7da5d565b8e3e114156e51950a9892cca67b402642d9edab8d6d366f64afc2b6&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43649&comment_hash=7da5d565b8e3e114156e51950a9892cca67b402642d9edab8d6d366f64afc2b6&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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to