Skip to content

Commit

Permalink
fix(ingestion): add fallback to trino (#6044)
Browse files Browse the repository at this point in the history
Co-authored-by: Pedro Silva <[email protected]>
  • Loading branch information
IceS2 and pedro93 authored Oct 6, 2022
1 parent f446cce commit 485d569
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion metadata-ingestion/src/datahub/ingestion/source/sql/trino.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,18 @@ def get_table_comment(self, connection, table_name: str, schema: str = None, **k
properties[col_name] = col_value

return {"text": properties.get("comment", None), "properties": properties}
# Fallback to default trino-sqlalchemy behaviour if `$properties` table doesn't exist
except TrinoQueryError as e:
if e.error_name in (
error.TABLE_NOT_FOUND,
error.COLUMN_NOT_FOUND,
error.NOT_FOUND,
):
return dict(text=None)
return self.get_table_comment_default(connection, table_name, schema)
# Exception raised when using Starburst Delta Connector that falls back to a Hive Catalog
except exc.ProgrammingError as e:
if isinstance(e.orig, TrinoQueryError):
return self.get_table_comment_default(connection, table_name, schema)
raise


Expand Down Expand Up @@ -118,6 +123,7 @@ def _get_columns(self, connection, table_name, schema: str = None, **kw): # typ
return columns


TrinoDialect.get_table_comment_default = TrinoDialect.get_table_comment
TrinoDialect.get_table_names = get_table_names
TrinoDialect.get_table_comment = get_table_comment
TrinoDialect._get_columns = _get_columns
Expand Down

0 comments on commit 485d569

Please sign in to comment.