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


##########
superset/common/query_context_processor.py:
##########
@@ -356,6 +361,39 @@ def get_df_payload_result(
                 # nonce reads the freshly-cached result instead of recomputing 
it.
                 self._mark_force_executed(query_obj, cache_key, 
cache.result_persisted)
 
+        # Annotation data is fetched per requesting user (and, for chart-backed
+        # layers, scoped by the referenced chart datasource's RLS), so it is
+        # resolved and cached under its own entry — independent of whether the
+        # (shareable) dataframe above was a hit or a miss — rather than forcing
+        # every viewer of the same chart onto their own full dataframe copy.
+        annotation_data: dict[str, Any] = {}
+        if (
+            query_obj
+            and query_obj.annotation_layers
+            and cache.status != QueryStatus.FAILED
+        ):
+            annotation_start_ns = time.perf_counter_ns()
+            try:
+                annotation_data = self._get_annotation_data_cached(
+                    query_obj=query_obj,
+                    cache_key=annotation_key,
+                    force_query=annotation_force_query,
+                    force_cached=force_cached,
+                    timeout=self.get_cache_timeout(),
+                    datasource_uid=self._qc_datasource.uid,
+                )
+            except SemanticResultCompletenessError:
+                raise
+            except QueryObjectValidationError as ex:
+                cache.error_message = str(ex)

Review Comment:
   When an annotation layer fails validation (for example a native layer that 
was deleted since the chart was saved), this stores a plain `str(ex)` instead 
of `QueryObjectValidationMessage(ex)`, as the dataframe path does a few lines 
above. `ChartDataCommand._raise_for_query_error` only raises the validation 
error type for the latter, so the same failure now surfaces as 
`ChartDataQueryFailedError`, where it used to be a validation error (400). 
Should this record `QueryObjectValidationMessage(ex)` so the error type is 
preserved?
   
   ```suggestion
                   cache.error_message = QueryObjectValidationMessage(ex)
   ```



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