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_r229840745
##########
File path: superset/views/core.py
##########
@@ -1200,17 +1186,30 @@ def annotation_json(self, layer_id):
form_data=form_data,
force=False,
)
- try:
- payload = viz_obj.get_payload()
- except Exception as e:
- logging.exception(e)
- return json_error_response(utils.error_msg_from_exception(e))
- status = 200
- if payload.get('status') == QueryStatus.FAILED:
- status = 400
- return json_success(viz_obj.json_dumps(payload), status=status)
+ payload_json_and_error = viz_obj.get_payload_json_and_error()
+ return self.payload_response(payload_json_and_error)
@log_this
+ @api
+ @handle_superset_exception
+ @has_access_api
+ @expose('/api/v1/query/', methods=['POST'])
+ def query(self):
+ """
+ Takes a query_obj constructed in the client and returns payload data
response
+ for the given query_obj. We assume the datasource for the query is
provided
+ as part of the query_obj and datasource contains the type and the id
field.
+ We also assume the viz_type is provided as part of the query_obj.
+ """
+ query_obj = json.loads(request.form.get('query_obj'),
+ object_hook=utils.decode_iso_dttm)
+ viz_obj = self.get_viz(query_obj=query_obj)
+ self.check_datasource_permission(viz_obj.datasource, g.user)
Review comment:
Same as mentioned above, this looks like it assumes that
`check_datasource_permission` raises
----------------------------------------------------------------
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]