This is an automated email from the ASF dual-hosted git repository.

arivero pushed a commit to branch time_comparison_zeros
in repository https://gitbox.apache.org/repos/asf/superset.git


The following commit(s) were added to refs/heads/time_comparison_zeros by this 
push:
     new 5d61eabce9 Time Comparison:
5d61eabce9 is described below

commit 5d61eabce95d8fcee09f357493e9e79dad54c79c
Author: Antonio Rivero <[email protected]>
AuthorDate: Mon Aug 19 19:21:24 2024 +0200

    Time Comparison:
    
    - Use different cache keys based on new offsets supported
---
 superset/common/query_context_processor.py | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/superset/common/query_context_processor.py 
b/superset/common/query_context_processor.py
index ece73c348a..40ec6008ea 100644
--- a/superset/common/query_context_processor.py
+++ b/superset/common/query_context_processor.py
@@ -493,9 +493,19 @@ class QueryContextProcessor:
                 if flt.get("col") != x_axis_label
             ]
 
+            # Inherit or custom start dates might compute the same offset but 
the response cannot be given
+            # using cached data unless you are using the same date of 
inherited range, that's why we
+            # set the cache cache using a custom key that includes the 
original offset and the computed offset
+            # for those two scenarios, the rest of the scenarios will use the 
original offset as cache key
+            cached_time_offset_key = (
+                offset if offset == original_offset else 
f"{offset}_{original_offset}"
+            )
+
             # `offset` is added to the hash function
             cache_key = self.query_cache_key(
-                query_object_clone, time_offset=offset, time_grain=time_grain
+                query_object_clone,
+                time_offset=cached_time_offset_key,
+                time_grain=time_grain,
             )
             cache = QueryCacheManager.get(
                 cache_key, CacheRegion.DATA, query_context.force

Reply via email to