mistercrunch commented on a change in pull request #6524: [SIP 6] Querycontext
improvement
URL:
https://github.com/apache/incubator-superset/pull/6524#discussion_r242377741
##########
File path: superset/common/query_context.py
##########
@@ -1,27 +1,244 @@
-# pylint: disable=R
+# pylint: disable=C,R,W
+from datetime import datetime, timedelta
+import logging
+import pickle as pkl
+import traceback
from typing import Dict, List
+import numpy as np
+import pandas as pd
+
+from superset import app, cache
from superset import db
from superset.connectors.connector_registry import ConnectorRegistry
+from superset.utils import core as utils
+from superset.utils.core import DTTM_ALIAS
from .query_object import QueryObject
+config = app.config
+stats_logger = config.get('STATS_LOGGER')
+
class QueryContext:
"""
The query context contains the query object and additional fields necessary
to retrieve the data payload for a given viz.
"""
+
+ default_fillna = 0
+ cache_type = 'df'
+ enforce_numerical_metrics = True
+
# TODO: Type datasource and query_object dictionary with TypedDict when it
becomes
# a vanilla python type https://github.com/python/mypy/issues/5288
def __init__(
self,
datasource: Dict,
queries: List[Dict],
+ force: bool = False,
+ custom_cache_timeout: int = None,
):
self.datasource =
ConnectorRegistry.get_datasource(datasource.get('type'),
int(datasource.get('id')),
db.session)
self.queries = list(map(lambda query_obj: QueryObject(**query_obj),
queries))
- def get_data(self):
- raise NotImplementedError()
+ self.force = force
+
+ self.custom_cache_timeout = custom_cache_timeout
+
+ self.enforce_numerical_metrics = True
+
+ def get_query_result(self, query_object):
Review comment:
I think a fair amount of the code here is copied from `viz.py`, reading the
PR it's hard to know whether it's been just copied or copied and then altered.
Even if the goal is to ultimately deprecate this logic from `viz.py` we should
still duplicate as little code as possible in the meantime. Could we do this
with a mixin class of some sort?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]