Skip to content

Commit

Permalink
Suppress failure when reading $partitions system table in get_indexes
Browse files Browse the repository at this point in the history
Not all connectors have a `$partitions` table. This caused `get_indexes`
to fail when called on a non-Hive (or non-partitioned Hive) table.

Since Trino engine doesn't have concept of partitions there's no single
way to fetch partition columns. One option is to parse the output of
`SHOW CREATE TABLE` to identify them but the logic would differ based on
what connector is being used. So we just opt to suppress the failure in
case of a non-Hive or non-partitioned Hive table instead.
  • Loading branch information
LittleWat authored and hashhar committed Dec 22, 2023
1 parent ab0e596 commit 9df2cf2
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion trino/sqlalchemy/dialect.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,12 @@ 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 = self._get_columns(connection, f"{table_name}$partitions", schema, **kw)
partitioned_columns = None
try:
partitioned_columns = self._get_columns(connection, f"{table_name}$partitions", schema, **kw)
except Exception as e:
# e.g. it's not a Hive table or an unpartitioned Hive table
logger.debug("Couldn't fetch partition columns. schema: %s, table: %s, error: %s", schema, table_name, e)
if not partitioned_columns:
return []
partition_index = dict(
Expand Down

0 comments on commit 9df2cf2

Please sign in to comment.