Skip to content

Commit

Permalink
fix url_params cache miss with global async query by setting global f…
Browse files Browse the repository at this point in the history
…orm_data

import flask g

fix linting

fix linting 2
  • Loading branch information
kekwan committed Apr 13, 2023
1 parent 95d71ff commit 6e0ff2b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion superset/charts/data/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from typing import Any, Dict, Optional, TYPE_CHECKING, Union

import simplejson
from flask import current_app, make_response, request, Response
from flask import current_app, g, make_response, request, Response
from flask_appbuilder.api import expose, protect
from flask_babel import gettext as _
from marshmallow import ValidationError
Expand Down Expand Up @@ -299,6 +299,9 @@ def data_from_cache(self, cache_key: str) -> Response:
"""
try:
cached_data = self._load_query_context_form_from_cache(cache_key)
# Set form_data in Flask Global as it is used as a fallback
# for async queries with jinja context
setattr(g, "form_data", cached_data)
query_context = self._create_query_context_from_form(cached_data)
command = ChartDataCommand(query_context)
command.validate()
Expand Down
4 changes: 3 additions & 1 deletion superset/views/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,9 @@ def explore_json_data(self, cache_key: str) -> FlaskResponse:

form_data = cached.get("form_data")
response_type = cached.get("response_type")

# Set form_data in Flask Global as it is used as a fallback
# for async queries with jinja context
setattr(g, "form_data", form_data)
datasource_id, datasource_type = get_datasource_info(None, None, form_data)

viz_obj = get_viz(
Expand Down

0 comments on commit 6e0ff2b

Please sign in to comment.