This is an automated email from the ASF dual-hosted git repository. johnbodley pushed a commit to branch john-bodley--trino-presto in repository https://gitbox.apache.org/repos/asf/superset.git
commit 7dc5950fab8646cfb53aa57e3590381cbc41438f Author: John Bodley <[email protected]> AuthorDate: Fri Jul 15 20:01:52 2022 -0700 fix: Ensure Presto database engine spec correctly handles Trino --- superset/db_engine_specs/presto.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/superset/db_engine_specs/presto.py b/superset/db_engine_specs/presto.py index cd6fa032b3..952574be09 100644 --- a/superset/db_engine_specs/presto.py +++ b/superset/db_engine_specs/presto.py @@ -940,8 +940,6 @@ class PrestoEngineSpec(BaseEngineSpec): # pylint: disable=too-many-public-metho :param schema: Schema name :param table: Table (view) name """ - # pylint: disable=import-outside-toplevel - from pyhive.exc import DatabaseError engine = cls.get_engine(database, schema) with closing(engine.raw_connection()) as conn: @@ -949,11 +947,12 @@ class PrestoEngineSpec(BaseEngineSpec): # pylint: disable=too-many-public-metho sql = f"SHOW CREATE VIEW {schema}.{table}" try: cls.execute(cursor, sql) + return cls.fetch_data(cursor, 1)[0][0] - except DatabaseError: # not a VIEW + # TODO(john-bodley): Replace with sqlalchemy.exc.DBAPIError after + # https://github.com/trinodb/trino-python-client/issues/199 is resolved. + except Exception: # pylint: disable=broad-exception return None - rows = cls.fetch_data(cursor, 1) - return rows[0][0] @classmethod def handle_cursor(cls, cursor: Any, query: Query, session: Session) -> None:
