sadpandajoe commented on code in PR #44851:
URL: https://github.com/apache/superset/pull/44851#discussion_r4172175287


##########
superset/semantic_layers/models.py:
##########
@@ -703,7 +721,18 @@ def data_for_slices(self, slices: list[Any]) -> 
ExplorableData:
         return self.data
 
     def get_extra_cache_keys(self, query_obj: QueryObjectDict) -> 
list[Hashable]:
-        return []
+        token: str | None = self.metadata_cache_token
+        return [token] if token is not None else []
+

Review Comment:
   Filter-value suggestions can still come from the old catalog after a 
successful metadata sync. The column-values endpoint builds its `col_values:` 
key from `uid` and `changed_on` without calling this hook; neither changes when 
an opted-in provider retains a stable UID and redefines a dimension upstream. 
Could that cache also include the captured metadata token, with coverage that 
warms values under T0, publishes T1, and verifies a fresh provider read?



##########
superset-frontend/src/explore/actions/exploreActions.ts:
##########
@@ -281,6 +290,63 @@ export function syncDatasourceMetadata(datasource: 
Dataset) {
   return { type: SYNC_DATASOURCE_METADATA, datasource };
 }
 
+export const SYNC_SEMANTIC_METADATA = 'explore/SYNC_SEMANTIC_METADATA';
+/** Rebuild metadata-derived controls without recording a chart edit. */
+export function syncSemanticMetadata(
+  datasource: Dataset,
+  formData: QueryFormData,
+): {
+  type: typeof SYNC_SEMANTIC_METADATA;
+  datasource: Dataset;
+  formData: QueryFormData;
+} {
+  return { type: SYNC_SEMANTIC_METADATA, datasource, formData };
+}
+
+/** Refresh the active view's metadata without saving or running the chart. */
+export function refreshSemanticMetadata(
+  viewId: number,
+  sessionIsCurrent: () => boolean,
+) {
+  return async (
+    dispatch: Dispatch,
+    getState: () => Pick<ExplorePageState, 'explore'>,
+  ) => {
+    const isActiveDatasource = () => {
+      const { datasource } = getState().explore;
+      return (
+        Number(datasource.id) === viewId &&
+        String(datasource.type) === 'semantic_view'
+      );
+    };
+    const isCurrent = () => sessionIsCurrent() && isActiveDatasource();
+    if (!isCurrent()) return;
+    // A pre-sync compatibility response cannot replace a post-sync answer.
+    compatibilityRequestSeq += 1;

Review Comment:
   A failed datasource-metadata GET, or closing the editor while that GET is 
pending, can leave Explore permanently in `loading`: the outstanding 
compatibility POST has been retired, but neither exit settles it or starts a 
replacement. Could these exits settle the retired request, with a regression 
that starts from an outstanding compatibility POST?



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