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


##########
superset/common/query_context_processor.py:
##########
@@ -72,7 +74,6 @@
     get_column_name,
     get_column_names_from_columns,
     get_column_names_from_metrics,
-    get_user_id,
     is_adhoc_column,

Review Comment:
   Dropping `get_user_id` here leaves the rest of the old annotation-context 
imports orphaned: `DatasourceDAO`, `DatasourceNotFound`, 
`DatasourceTypeNotSupportedError`, `DatasourceValueIsIncorrect`, `json` and the 
`TYPE_CHECKING` `Datasource` no longer have any reference in this file now that 
`_annotation_source_scope` resolves the datasource through the chart's query 
context. Ruff's F401 will fail lint/pre-commit on the changed file. Can these 
be removed in the same pass?



##########
superset/common/query_context_processor.py:
##########
@@ -343,6 +355,32 @@ 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

Review Comment:
   The caller-level wiring around this block has no direct coverage: every new 
`get_df_payload_result` test either supplies a successful dataframe cache or 
replaces `_get_annotation_data_cached` with a mock. If someone drops the 
`cache.status != QueryStatus.FAILED` guard, a failed dataframe would still 
trigger the annotation fetch, and an annotation exception could replace the 
original failure response; likewise nothing asserts the annotation nonce marker 
is written only when `set_and_log_cache` actually persisted (the existing 
marker tests call `_mark_force_executed` directly). Could a test drive 
`get_df_payload_result` with annotation layers through the real helper for both 
a failed dataframe (annotation helper not called, `annotation_data == {}`, 
original error kept) and a non-persisting annotation write (no marker, next 
same-nonce read still forces)?



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