mikebridge commented on code in PR #43649:
URL: https://github.com/apache/superset/pull/43649#discussion_r3882981441
##########
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:
Thanks — accurate on the mechanics, but pre-existing and out of scope.
`ChartGetResponseSchema.datasource_uuid` reads `table.uuid`, so for
semantic-view charts the key is omitted today exactly as it was before this PR
(this change only touches the display helpers behind the list's name/link).
There are no in-repo consumers of `datasource_uuid`, and its current meaning is
"dataset UUID": filling it with a semantic view's UUID would mislead any client
that resolves it against `/api/v1/dataset/`. Exposing a typed
`(datasource_type, datasource_uuid)` pair belongs with reconciling
`Slice.datasource` across datasource kinds, which is tracked as a follow-up
rather than widened into this fix.
--
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]