From notifications-return-20109-archive-asf-public=cust-asf.ponee.io@superset.apache.org Thu May 2 16:57:55 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id 050BB180671 for ; Thu, 2 May 2019 18:57:54 +0200 (CEST) Received: (qmail 18543 invoked by uid 500); 2 May 2019 16:57:54 -0000 Mailing-List: contact notifications-help@superset.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@superset.apache.org Delivered-To: mailing list notifications@superset.apache.org Received: (qmail 18534 invoked by uid 99); 2 May 2019 16:57:54 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 02 May 2019 16:57:54 +0000 From: GitBox To: notifications@superset.apache.org Subject: [GitHub] [incubator-superset] bearcage 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 Message-ID: <155681627430.20487.13012125852328988022.gitbox@gitbox.apache.org> Date: Thu, 02 May 2019 16:57:54 -0000 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit bearcage 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_r280509948 ########## 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 think ideally we'd give the client a way to know ahead of time whether a selected db can do validation at all, so we don't have to try the endpoint and trap the error. I'm not entirely sure how to plumb that part, though, so the client code I have right now does 3b — it just keeps on trying pretending nobody ever told it that it'll never work. ---------------------------------------------------------------- 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