From 338147b352b183e4deb0501ad77cc3e9bec67f6f Mon Sep 17 00:00:00 2001 From: Kohei Watanabe Date: Mon, 18 Dec 2023 20:35:26 +0900 Subject: [PATCH] fix the exception handling in `get_indexes` func based on [the review comment](https://github.com/trinodb/trino-python-client/pull/426#discussion_r1426255876) --- trino/sqlalchemy/dialect.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/trino/sqlalchemy/dialect.py b/trino/sqlalchemy/dialect.py index 21011b6f..690c8219 100644 --- a/trino/sqlalchemy/dialect.py +++ b/trino/sqlalchemy/dialect.py @@ -29,7 +29,6 @@ OAuth2Authentication, ) from trino.dbapi import Cursor -from trino.exceptions import TrinoUserError from trino.sqlalchemy import compiler, datatype, error logger = logging.get_logger(__name__) @@ -281,11 +280,11 @@ def get_indexes(self, connection: Connection, table_name: str, schema: str = Non if not self.has_table(connection, table_name, schema): raise exc.NoSuchTableError(f"schema={schema}, table={table_name}") + partitioned_columns = None try: partitioned_columns = self._get_columns(connection, f"{table_name}$partitions", schema, **kw) - # some connector does not support $partitions table suffix so trying without appending that - except TrinoUserError: - partitioned_columns = self._get_columns(connection, table_name, schema, **kw) + except Exception as e: + logger.debug("Couldn't fetch partition columns for ... err: %s", e) if not partitioned_columns: return [] partition_index = dict(