Skip to content

ClickHouse query runner: fixed error message #6764

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Mar 17, 2024
8 changes: 6 additions & 2 deletions redash/query_runner/clickhouse.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,19 @@ def _send_query(self, data, session_id=None, session_check=None):
verify=verify,
)

if r.status_code != 200:
if not r.ok:
raise Exception(r.text)

# In certain situations the response body can be empty even if the query was successful, for example
# when creating temporary tables.
if not r.text:
return {}

return r.json()
response = r.json()
if "exception" in response:
raise Exception(response["exception"])

return response
except requests.RequestException as e:
if e.response:
details = "({}, Status Code: {})".format(e.__class__.__name__, e.response.status_code)
Expand Down