superset-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <>
Subject [GitHub] [incubator-superset] john-bodley opened a new pull request #8256: [sql_json] Ensuring the request body is JSON encoded
Date Wed, 18 Sep 2019 23:47:40 GMT
john-bodley opened a new pull request #8256: [sql_json] Ensuring the request body is JSON encoded
   Choose one
   - [x] Bug Fix
   - [ ] Enhancement (new features, refinement)
   - [ ] Refactor
   - [ ] Add tests
   - [ ] Build / Development Environment
   - [ ] Documentation
   ### SUMMARY
   Somewhat of a yak-shaving PR as the intent was to fix an issue where Hive queries failed
in SQL Lab if no schema was selected, 
   ![Screen Shot 2019-09-18 at 3 54 58 PM](
   The error is coming from [here](
in PyHive where it seems that the schema (database) is being defined via the `"null"` string
as opposed to `None`.
   The root cause of this is in the front-end the `SupersetClient` has passing the data as
form data (using the `multipart/form-data` Content-Type header) which was then being processed
in Flask via [`response.form`](
This meant everything was being encoded as strings, i.e., hence why we had logic like,
   request.form.get("runAsync") == "true"
   and why `null` was being encoded as `"null"` as opposed to `None`. The fix was to:
   1. Ensure that the front-end correctly encodes the body as JSON (and sets the appropriate
   2. Use [`response.json`](
to correctly process the response.
   3. Remove the obsolete `GET` method to `sql_json`. 
   4. For testing use the somewhat misnamed `json` argument to Flask's test ``
method which is actually a Python dictionary (ironically the `data` argument can be a JSON
string) and removes the need to specify the Content-Type header (which is needed for `response.json`
otherwise we would need to use `response.get_json(force=True)` which seems a little heavy
   ### TEST PLAN
   <!--- Check any relevant boxes with "x" -->
   <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
   - [ ] Has associated issue:
   - [ ] Changes UI
   - [ ] Requires DB Migration.
   - [ ] Confirm DB Migration upgrade and downgrade tested.
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   to: @etr2460 @graceguo-supercat @williaster 
   cc: @mistercrunch @villebro 

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:

With regards,
Apache Git Services

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message