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


##########
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:
   ✅ **Customized review instruction saved!**
   
   **Instruction:**
   > Do not populate datasource_uuid with a semantic-view UUID; preserve its 
existing dataset-UUID semantics until a typed datasource identifier is 
introduced.
   
   **Applied to:**
     - `superset/models/slice.py`
   
   ---
   💡 *To manage or update this instruction, visit: [CodeAnt AI 
Settings](https://app.codeant.ai/org/settings/learnings)*



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