SEPURI-SAI-KRISHNA commented on code in PR #43222:
URL: https://github.com/apache/superset/pull/43222#discussion_r3789704977


##########
superset/common/query_context_processor.py:
##########
@@ -442,9 +460,7 @@ def ensure_totals_available(
         result = self._query_context.get_query_result(totals_query)
         df = result.df
 
-        totals = {
-            col: df[col].sum() for col in df.columns if df[col].dtype.kind in 
"biufc"
-        }
+        totals = {col: df[col].sum() for col in df.columns if 
_is_summable(df[col])}

Review Comment:
   Thanks, I dug into both cache paths, and the mechanism doesn't apply here.
   
   The per-query data cache key never sees these totals. 
`QueryObject.cache_key()` strips them explicitly before hashing:
   
   ```python
   if pp_copy.get("operation") == "contribution" and "options" in pp_copy:
       options = dict(pp_copy["options"])
       # Remove contribution_totals as it's dynamically calculated
       options.pop("contribution_totals", None)
   ```
   
   The QueryContext cache key does include them, via the 
`cache_values["queries"]` sync, and `generate_cache_key` does hash through 
`json_int_dttm_ser`, which turns `Decimal` into `float`, I confirmed 
`json_int_dttm_ser(Decimal("1.0000000000000000001"))` returns `1.0`. But that 
cannot collapse two otherwise-distinct keys, because `contribution_totals` is 
derived from the query definitions that are already in the key. Two contexts 
that hash alike have identical queries, and identical queries produce identical 
totals; the field adds no entropy of its own.
   
   The one case where totals vary independently is the underlying data changing 
between requests. There, this change strictly improves matters: on `master` 
Decimal totals are absent from the key altogether, so it never varies with them
   at all. After this change it varies except beyond float precision. Strictly 
more sensitive than the status quo, never less.
   



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