mistercrunch commented on a change in pull request #6220: [SIP-5] Open a new
/api/v1/query endpoint that takes query_obj
URL:
https://github.com/apache/incubator-superset/pull/6220#discussion_r229841561
##########
File path: superset/viz.py
##########
@@ -63,22 +65,42 @@ class BaseViz(object):
cache_type = 'df'
enforce_numerical_metrics = True
- def __init__(self, datasource, form_data, force=False):
- if not datasource:
- raise Exception(_('Viz is missing a datasource'))
+ def __init__(self, datasource, form_data, query_obj={}, force=False):
+ if datasource:
+ self.datasource = datasource
+ else:
+ datasource_dict = query_obj.get('datasource', {})
+ ds = ConnectorRegistry.get_datasource(
+ datasource_dict.get('type'), datasource_dict.get('id'),
db.session)
+ if not ds:
+ raise Exception(_('Viz is missing a datasource'))
+ else:
Review comment:
NIT: no need for an else when the if clause exits
----------------------------------------------------------------
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]