Skip to content
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

DB API raises exceptions which are not derived from the PEP 249 database API specification #199

Closed
john-bodley opened this issue Jul 15, 2022 · 2 comments · Fixed by #204

Comments

@john-bodley
Copy link
Contributor

john-bodley commented Jul 15, 2022

The Trino DB API raises exceptions outside the PEP 249 database API specification and thus are not correctly handled by downstream interfaces including SQLAlchemy, Apache Superset, etc.

For example the DB API cursor fetchall method is raising a TrinoUserError which is not derived from a PEP 249 exception.

...
  File "/usr/local/lib/python3.9/dist-packages/trino/dbapi.py", line 560, in fetchall
    return list(self.genall())
  File "/usr/local/lib/python3.9/dist-packages/trino/client.py", line 512, in __iter__
    rows = self._query.fetch()
  File "/usr/local/lib/python3.9/dist-packages/trino/client.py", line 685, in fetch
    status = self._request.process(response)
  File "/usr/local/lib/python3.9/dist-packages/trino/client.py", line 443, in process
    raise self._process_error(response["error"], response.get("id"))
trino.exceptions.TrinoUserError: TrinoUserError(type=USER_ERROR, name=NOT_SUPPORTED, message="line 1:1: Relation 'foo.bar' is a table, not a view", query_id=20220715_233855_30555_sz8ja)

The resolution is that the public DB API methods should only raise PEP 249 exceptions.

@hashhar
Copy link
Member

hashhar commented Jul 18, 2022

The resolution is that the public DB API methods should only raise PEP 249 exceptions.

Or change existing exceptions to be subclasses of the predefined ones. Thanks for reporting this. Can you elaborate a bit on what you mean by "are not correctly handled by downstream interfaces including SQLAlchemy, Apache Superset, etc."? What do you observe?

@john-bodley
Copy link
Contributor Author

@hashhar see apache/superset#20729 for details, specifically this comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

2 participants