diff --git a/redash/query_runner/db2.py b/redash/query_runner/db2.py index 3253cee0b9..7413189459 100644 --- a/redash/query_runner/db2.py +++ b/redash/query_runner/db2.py @@ -3,7 +3,7 @@ import logging from redash.query_runner import * -from redash.utils import JSONEncoder +from redash.utils import json_dumps logger = logging.getLogger(__name__) @@ -129,7 +129,7 @@ def run_query(self, query, user): data = {'columns': columns, 'rows': rows} error = None - json_data = json.dumps(data, cls=JSONEncoder) + json_data = json_dumps(data) else: error = 'Query completed but it returned no data.' json_data = None diff --git a/redash/query_runner/kylin.py b/redash/query_runner/kylin.py index a9f5d1fdb4..261fa3f5e0 100644 --- a/redash/query_runner/kylin.py +++ b/redash/query_runner/kylin.py @@ -1,12 +1,11 @@ import os -import json import logging import requests from requests.auth import HTTPBasicAuth from redash import settings from redash.query_runner import * -from redash.utils import JSONEncoder +from redash.utils import json_dumps logger = logging.getLogger(__name__) @@ -102,7 +101,7 @@ def run_query(self, query, user): columns = self.get_columns(data['columnMetas']) rows = self.get_rows(columns, data['results']) - return json.dumps({'columns': columns, 'rows': rows}), None + return json_dumps({'columns': columns, 'rows': rows}), None def get_schema(self, get_stats=False): url = self.configuration['url'] diff --git a/redash/query_runner/rockset.py b/redash/query_runner/rockset.py index 5d0d30d99d..eafb41c822 100644 --- a/redash/query_runner/rockset.py +++ b/redash/query_runner/rockset.py @@ -1,8 +1,6 @@ import requests -import os from redash.query_runner import * -from redash.utils import JSONEncoder -import json +from redash.utils import json_dumps def _get_type(value): @@ -96,7 +94,7 @@ def run_query(self, query, user): columns = [] for k in rows[0]: columns.append({'name': k, 'friendly_name': k, 'type': _get_type(rows[0][k])}) - data = json.dumps({'columns': columns, 'rows': rows}, cls=JSONEncoder) + data = json_dumps({'columns': columns, 'rows': rows}) return data, None diff --git a/redash/serializers.py b/redash/serializers.py index 449e882a22..155e02620c 100644 --- a/redash/serializers.py +++ b/redash/serializers.py @@ -8,7 +8,6 @@ from flask_login import current_user from redash import models -from redash.handlers.query_results import run_query_sync from redash.permissions import has_access, view_only from redash.utils import json_loads from redash.models.parameterized_query import ParameterizedQuery @@ -31,6 +30,9 @@ def public_widget(widget): # make sure the widget's query has a latest_query_data_id that is # not null so public dashboards work if q.latest_query_data_id is None: + # this import is inline since it triggers a circular + # import otherwise + from redash.handlers.query_results import run_query_sync run_query_sync(q.data_source, {}, q.query_text) query_data = q.latest_query_data.to_dict()