bito-code-review[bot] commented on PR #44681:
URL: https://github.com/apache/superset/pull/44681#issuecomment-5849589465

   <!-- Bito Reply -->
   The flagged issue is correct. The `datasource_name` column in the `Slice` 
model is a denormalized, stored value that does not automatically update when a 
dataset is renamed or a chart is re-pointed, leading to stale data. 
   
   To resolve this, the pull request introduces `resolve_chart_datasource_name` 
in `superset/mcp_service/chart/schemas.py`, which attempts to resolve the name 
through live relationships (`table` or `semantic_view`) before falling back to 
the stored column. The `_ChartListCore` class in 
`superset/mcp_service/chart/tool/list_charts.py` is also updated to ensure 
these relationships are eager-loaded when `datasource_name` is requested, 
ensuring the live name is used without additional per-chart queries.
   
   **superset/mcp_service/chart/schemas.py**
   ```
   def resolve_chart_datasource_name(chart: Any) -> str | None:
       """Return the chart's datasource name, read from the live datasource.
   
       ``Slice.datasource_name`` is a stored, denormalized column that is not
       refreshed when a dataset is renamed or a chart is re-pointed, so it can
       name a table the chart no longer queries. ``Slice.datasource_name_text``
       resolves the name through the type-guarded ``table`` / ``semantic_view``
       relationships instead, and yields ``None`` when the datasource no longer
       exists. Objects without that resolver (row tuples, lightweight stand-ins)
       fall back to the stored value.
       """
       resolver = getattr(chart, "datasource_name_text", None)
       if callable(resolver):
           live_name = resolver()
           if live_name is None or isinstance(live_name, str):
               return live_name
       stored_name = getattr(chart, "datasource_name", None)
       return stored_name if isinstance(stored_name, str) else None
   ```


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