mirror of
https://github.com/apache/superset.git
synced 2026-04-25 11:04:48 +00:00
fix: double computation of contribution_totals (#36226)
This commit is contained in:
@@ -299,20 +299,24 @@ class QueryContextProcessor:
|
||||
) -> dict[str, Any]:
|
||||
"""Returns the query results with both metadata and data"""
|
||||
|
||||
self.ensure_totals_available()
|
||||
# Skip ensure_totals_available when force_cached=True
|
||||
# This prevents recalculating contribution_totals from cached results
|
||||
if not force_cached:
|
||||
self.ensure_totals_available()
|
||||
|
||||
# Update cache_values to reflect modifications made by ensure_totals_available()
|
||||
# This ensures cache keys are generated from the actual query state
|
||||
# We merge the original query dict with the updated query dict to preserve
|
||||
# any fields that might not be in to_dict() but were in the original request
|
||||
self._query_context.cache_values["queries"] = [
|
||||
{**cached_query, **query.to_dict()}
|
||||
for cached_query, query in zip(
|
||||
self._query_context.cache_values["queries"],
|
||||
self._query_context.queries,
|
||||
strict=True,
|
||||
)
|
||||
]
|
||||
# Update cache_values to reflect modifications made by
|
||||
# ensure_totals_available()
|
||||
# This ensures cache keys are generated from the actual query state
|
||||
# We merge the original query dict with the updated query dict to preserve
|
||||
# any fields that might not be in to_dict() but were in the original request
|
||||
self._query_context.cache_values["queries"] = [
|
||||
{**cached_query, **query.to_dict()}
|
||||
for cached_query, query in zip(
|
||||
self._query_context.cache_values["queries"],
|
||||
self._query_context.queries,
|
||||
strict=True,
|
||||
)
|
||||
]
|
||||
|
||||
query_results = [
|
||||
get_query_results(
|
||||
|
||||
Reference in New Issue
Block a user