superset-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [incubator-superset] DiggidyDave commented on a change in pull request #7422: [WIP] Add `validate_sql_json` endpoint for checking that a given sql query is valid for the chosen database
Date Thu, 02 May 2019 16:43:53 GMT
DiggidyDave commented on a change in pull request #7422: [WIP] Add `validate_sql_json` endpoint
for checking that a given sql query is valid for the chosen database
URL: https://github.com/apache/incubator-superset/pull/7422#discussion_r280504569
 
 

 ##########
 File path: superset/views/core.py
 ##########
 @@ -2503,6 +2504,61 @@ def stop_query(self):
             pass
         return self.json_response('OK')
 
+    @has_access_api
+    @expose('/validate_sql_json/', methods=['POST', 'GET'])
+    @log_this
+    def validate_sql_json(self):
+        """Validates that arbitrary sql is acceptable for the given database.
+        Returns a list of error/warning annotations as json.
+        """
+        sql = request.form.get('sql')
+        database_id = request.form.get('database_id')
+        schema = request.form.get('schema') or None
+        template_params = json.loads(
+            request.form.get('templateParams') or '{}')
+
+        if len(template_params) > 0:
+            # TODO: factor the Database object out of template rendering
+            #       or provide it as mydb so we can render template params
+            #       without having to also persist a Query ORM object.
+            return json_error_response(
 
 Review comment:
   I don't think we want to return 500s here. This is an unexceptional condition, it will
happen frequently, right? Maybe 404?
   
   What's the flow expected to be? Is it something like this?
   
   1) Client requests validation...
   2) Server says "nope I can't do templates yet"
   3a) Client says to itself "awww man" and stops requesting validation until the query changes
substantially
   or...
   3b) Client disregards the response and keeps querying at reasonable points? (I sort of
favor 3b because it keeps the client simple and gives us a single endpoint to concern ourselves
with w.r.t. scale)

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Mime
View raw message