-
Notifications
You must be signed in to change notification settings - Fork 194
Description
Expected behavior
When the error
field in the REST response is null
(None
for the python client), assume a successful execution.
From the docs:
If query failed, the error attribute contains a QueryError object. That object contains a message, an errorCode and other information about the error. See the io.trino.client.QueryError class in module trino-client in the client directory for more details.
queryError | QueryError | Non-null only if the query resulted in an error.
Actual behavior
An exception is thrown in the client:
Traceback (most recent call last):
File "/OBFUSCATED/main.py", line 29, in <module>
main()
File "/OBFUSCATED/main.py", line 25, in main
asyncio.run(trino_scraper.start())
File "/root/.pyenv/versions/3.11.10/lib/python3.11/asyncio/runners.py", line 190, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "/root/.pyenv/versions/3.11.10/lib/python3.11/asyncio/runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/.pyenv/versions/3.11.10/lib/python3.11/asyncio/base_events.py", line 654, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/OBFUSCATED/scrapers.py", line 165, in start
cur.execute(
File "/OBFUSCATED/.venv/lib/python3.11/site-packages/trino/dbapi.py", line 585, in execute
self._iterator = iter(self._query.execute())
^^^^^^^^^^^^^^^^^^^^^
File "/OBFUSCATED/.venv/lib/python3.11/site-packages/trino/client.py", line 814, in execute
status = self._request.process(response)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/OBFUSCATED/.venv/lib/python3.11/site-packages/trino/client.py", line 619, in process
raise self._process_error(response["error"], response.get("id"))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/OBFUSCATED/.venv/lib/python3.11/site-packages/trino/client.py", line 584, in _process_error
error_type = error["errorType"]
~~~~~^^^^^^^^^^^^^
TypeError: 'NoneType' object is not subscriptable
Steps To Reproduce
Not yet sure what causes my Trino installation to give out a None
value for the error
field in the HTTP response instead of omitting the filed altogether, or even if this is not actually just standard behavior.
What does fix it for me is a simple patch in client.py
:
def process(self, http_response) -> TrinoStatus:
...
if "error" in response and response["error"]:
...
Log output
No response
Operating System
alpine (container environment)
Trino Python client version
0.331.0
Trino Server version
450
Python version
3.11.0
Are you willing to submit PR?
- Yes I am willing to submit a PR!