Skip to content

Commit

Permalink
Fix cache keys
Browse files Browse the repository at this point in the history
  • Loading branch information
betodealmeida committed Aug 6, 2024
1 parent 5e7d979 commit 9023b48
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
10 changes: 6 additions & 4 deletions superset/connectors/sqla/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,9 +461,11 @@ def data_for_slices( # pylint: disable=too-many-locals
)
else:
_columns = [
utils.get_column_name(column_)
if utils.is_adhoc_column(column_)
else column_
(
utils.get_column_name(column_)
if utils.is_adhoc_column(column_)
else column_
)
for column_param in COLUMN_FORM_DATA_PARAMS
for column_ in utils.as_list(form_data.get(column_param) or [])
]
Expand Down Expand Up @@ -1963,7 +1965,7 @@ class and any keys added via `ExtraCache`.
if self.has_extra_cache_key_calls(query_obj):
sqla_query = self.get_sqla_query(**query_obj)
extra_cache_keys += sqla_query.extra_cache_keys
return extra_cache_keys
return list(set(extra_cache_keys))

@property
def quote_identifier(self) -> Callable[[str], str]:
Expand Down
1 change: 0 additions & 1 deletion superset/jinja_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,6 @@ def process_template(self, sql: str, **kwargs: Any) -> str:
kwargs.update(self._context)

context = validate_template_context(self.engine, kwargs)
print("FOO", type(template.render(context)))
return template.render(context)


Expand Down
6 changes: 4 additions & 2 deletions tests/integration_tests/sqla_models_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@
from superset.constants import EMPTY_STRING, NULL_STRING
from superset.db_engine_specs.bigquery import BigQueryEngineSpec
from superset.db_engine_specs.druid import DruidEngineSpec
from superset.exceptions import QueryObjectValidationError, SupersetSecurityException # noqa: F401
from superset.exceptions import (
QueryObjectValidationError,
) # noqa: F401
from superset.models.core import Database
from superset.utils.core import (
AdhocMetricExpressionType,
Expand Down Expand Up @@ -160,7 +162,7 @@ def test_extra_cache_keys(self, mock_user_email, mock_username, mock_user_id):
query_obj = dict(**base_query_obj, extras={})
extra_cache_keys = table1.get_extra_cache_keys(query_obj)
self.assertTrue(table1.has_extra_cache_key_calls(query_obj))
assert extra_cache_keys == [1, "abc", "abc@test.com"]
assert set(extra_cache_keys) == {1, "abc", "abc@test.com"}

# Table with Jinja callable disabled.
table2 = SqlaTable(
Expand Down

0 comments on commit 9023b48

Please sign in to comment.