mirror of
https://github.com/apache/superset.git
synced 2026-04-19 08:04:53 +00:00
Fix sqla query cache keys function (#8105)
This commit is contained in:
@@ -119,7 +119,7 @@ class QueryContext:
|
||||
def get_data(self, df):
|
||||
return df.to_dict(orient="records")
|
||||
|
||||
def get_single_payload(self, query_obj):
|
||||
def get_single_payload(self, query_obj: QueryObject):
|
||||
"""Returns a payload of metadata and data"""
|
||||
payload = self.get_df_payload(query_obj)
|
||||
df = payload.get("df")
|
||||
@@ -134,8 +134,8 @@ class QueryContext:
|
||||
return payload
|
||||
|
||||
def get_payload(self):
|
||||
"""Get all the paylaods from the arrays"""
|
||||
return [self.get_single_payload(query_ojbect) for query_ojbect in self.queries]
|
||||
"""Get all the payloads from the arrays"""
|
||||
return [self.get_single_payload(query_object) for query_object in self.queries]
|
||||
|
||||
@property
|
||||
def cache_timeout(self):
|
||||
@@ -150,9 +150,9 @@ class QueryContext:
|
||||
return self.datasource.database.cache_timeout
|
||||
return config.get("CACHE_DEFAULT_TIMEOUT")
|
||||
|
||||
def get_df_payload(self, query_obj, **kwargs):
|
||||
def get_df_payload(self, query_obj: QueryObject, **kwargs):
|
||||
"""Handles caching around the df paylod retrieval"""
|
||||
extra_cache_keys = self.datasource.get_extra_cache_keys(query_obj)
|
||||
extra_cache_keys = self.datasource.get_extra_cache_keys(query_obj.to_dict())
|
||||
cache_key = (
|
||||
query_obj.cache_key(
|
||||
datasource=self.datasource.uid,
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
from collections import OrderedDict
|
||||
from datetime import datetime
|
||||
import logging
|
||||
from typing import Any, List, NamedTuple, Optional, Union
|
||||
from typing import Any, Dict, List, NamedTuple, Optional, Union
|
||||
|
||||
from flask import escape, Markup
|
||||
from flask_appbuilder import Model
|
||||
@@ -1064,7 +1064,7 @@ class SqlaTable(Model, BaseDatasource):
|
||||
def default_query(qry):
|
||||
return qry.filter_by(is_sqllab_view=False)
|
||||
|
||||
def get_extra_cache_keys(self, query_obj) -> List[Any]:
|
||||
def get_extra_cache_keys(self, query_obj: Dict) -> List[Any]:
|
||||
sqla_query = self.get_sqla_query(**query_obj)
|
||||
return sqla_query.extra_cache_keys
|
||||
|
||||
|
||||
Reference in New Issue
Block a user