tien238lnd commented on code in PR #44633:
URL: https://github.com/apache/superset/pull/44633#discussion_r4101803470
##########
superset/connectors/sqla/models.py:
##########
@@ -1903,6 +1903,14 @@ def time_grain_sqla(self) -> list[tuple[Any, Any]]:
@property
def data(self) -> ExplorableData:
data_ = super().data
+ # Editors gate the "Edit dataset" action in Explore. They are
serialized
+ # with the same compact subject shape the dataset REST API exposes
+ # (``editors.id`` / ``editors.label`` / ``editors.type``) so both
+ # payloads can be consumed by the same frontend code.
+ data_["editors"] = [
+ {"id": editor.id, "label": editor.label, "type": editor.type}
+ for editor in self.editors
+ ]
Review Comment:
Thanks — the call sites are accurate, but the premise that "each
`SqlaTable.data` call now issues a lazy-load query" is not: `editors` is a lazy
relationship, so SQLAlchemy loads it once per instance and serves every later
access from instance state. The three `client_processing` helpers listed here
run against the same datasource object, so together they cost one query, not
three. `data_for_slices` already relies on that caching — it calls `self.data`
and then reads `self.verbose_map` and `self.column_names`, all of which walk
`self.columns`.
So the real cost is one extra query per datasource per request, on top of
the three `.data` already pays for: `columns`, `metrics` and `database` are all
declared without an eager loading strategy either.
I'm keeping it in `.data`, for two reasons beyond that:
- `Slice.data` already serializes its editors this way, and lands in the
same Explore payload (`result["slice"]`).
- `ExplorableData` declares `editors` as a field of this payload
(`superset/superset_typing.py`), so the typed contract puts it here.
If a maintainer would rather scope it to the one endpoint that reads it,
moving the assignment into `GetExploreCommand` is a small change — the
`views/core.py` explore route is `@deprecated()`, which leaves a single live
call site. Happy to do that on request.
_🤖 Addressed by [Claude Code](https://claude.com/claude-code)_
--
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]