michael-s-molina commented on code in PR #19981: URL: https://github.com/apache/superset/pull/19981#discussion_r870541833
########## tests/integration_tests/utils/cache_manager_tests.py: ########## @@ -0,0 +1,50 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +import pytest + +from superset.extensions import cache_manager +from superset.utils.core import DatasourceType + Review Comment: Can we add a test that checks for retrieval using keys that were generated without a datasource type? ########## superset-frontend/src/explore/components/controls/DatasourceControl/index.jsx: ########## @@ -189,9 +189,10 @@ class DatasourceControl extends React.PureComponent { const isMissingDatasource = datasource.id == null; let isMissingParams = false; if (isMissingDatasource) { - const datasetId = getUrlParam(URL_PARAMS.datasetId); + const datasourceId = getUrlParam(URL_PARAMS.datasourceId); + const datasourceType = getUrlParam(URL_PARAMS.datasourceType); const sliceId = getUrlParam(URL_PARAMS.sliceId); - if (!datasetId && !sliceId) { + if (!datasourceId && !sliceId && !datasourceType) { Review Comment: We need to consider old URLs that use the `datasetId`. Maybe read the old parameter and assign it to `datasourceId` and set `datasourceType` to `table`. We also need to change the alert message `'The URL is missing the dataset_id or slice_id parameters.'` to also include the `dataset_type`. ########## superset/utils/cache_manager.py: ########## @@ -15,15 +15,40 @@ # specific language governing permissions and limitations # under the License. import logging +from typing import Any, Optional, Union from flask import Flask from flask_caching import Cache +from markupsafe import Markup + +from superset.utils.core import DatasourceType logger = logging.getLogger(__name__) CACHE_IMPORT_PATH = "superset.extensions.metastore_cache.SupersetMetastoreCache" +class ExploreFormDataCache(Cache): + def get(self, *args: Any, **kwargs: Any) -> Optional[Union[str, Markup]]: + cache = self.cache.get(*args, **kwargs) Review Comment: There's a problem here with old keys because the `contextual_key` is now being generated with the `datasource_type` but the old keys didn't have it so it will miss the cache and return `None` for old keys. -- 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]
