trinodb / trino-python-client

Python client for Trino
Apache License 2.0
309 stars 151 forks source link

'Engine' object has no attribute 'connection' when calling get_table_comment #253

Closed ganczarek closed 1 year ago

ganczarek commented 1 year ago

Expected behavior

Call to get_table_comment should not fail.

Actual behavior

When calling get_table_comment from Superset it fails with the following error:

2022-10-07 14:06:52,206:ERROR:root:'Engine' object has no attribute 'connection'
Traceback (most recent call last):
  File "/opt/superset/superset/db_engine_specs/base.py", line 1026, in get_table_comment
    comment = inspector.get_table_comment(table_name, schema)
  File "/usr/local/lib/python3.8/site-packages/sqlalchemy/engine/reflection.py", line 558, in get_table_comment
    return self.dialect.get_table_comment(
  File "/usr/local/lib/python3.8/site-packages/trino/sqlalchemy/dialect.py", line 267, in get_table_comment
    catalog_name = self._get_default_catalog_name(connection)
  File "/usr/local/lib/python3.8/site-packages/trino/sqlalchemy/dialect.py", line 336, in _get_default_catalog_name
    dbapi_connection: trino_dbapi.Connection = connection.connection
AttributeError: 'Engine' object has no attribute 'connection'

A similar issue was fixed in PyAthena: https://github.com/laughingman7743/PyAthena/issues/63. It makes me believe that the problem is not in Superset, but Trino client.

Steps To Reproduce

If you have a Superset setup with a Trino client, then:

Log output

No response

Operating System

Debian buster in Docker image python:3.8.13-slim-buster

Trino Python client version

0.316.0

Trino Server version

378.amzn.0

Python version

3.8.13

Are you willing to submit PR?

mdesmet commented 1 year ago

Tested with Superset (master), dev version of trino-python-client and sqlalchemy 1.4

image

No errors in superset log