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.