@@ -262,19 +262,26 @@ def get_check_constraints(
262262 return []
263263
264264 def get_table_comment (self , connection : Connection , table_name : str , schema : str = None , ** kw ) -> Dict [str , Any ]:
265- schema = schema or self ._get_default_schema_name (connection )
266- if schema is None :
265+ catalog_name = self ._get_default_catalog_name (connection )
266+ if catalog_name is None :
267+ raise exc .NoSuchTableError ("catalog is required in connection" )
268+ schema_name = schema or self ._get_default_schema_name (connection )
269+ if schema_name is None :
267270 raise exc .NoSuchTableError ("schema is required" )
268271 query = dedent (
269272 """
270273 SELECT "comment"
271274 FROM "system"."metadata"."table_comments"
272- WHERE "schema_name" = :schema
273- AND "table_name" = :table_name
275+ WHERE "catalog_name" = :catalog_name
276+ AND "schema_name" = :schema_name
277+ AND "table_name" = :table_name
274278 """
275279 ).strip ()
276280 try :
277- res = connection .execute (sql .text (query ), schema = schema , table_name = table_name )
281+ res = connection .execute (
282+ sql .text (query ),
283+ catalog_name = catalog_name , schema_name = schema_name , table_name = table_name
284+ )
278285 return dict (text = res .scalar ())
279286 except error .TrinoQueryError as e :
280287 if e .error_name in (
@@ -323,6 +330,10 @@ def _get_server_version_info(self, connection: Connection) -> Any:
323330 logger .debug (f"Failed to get server version: { e .orig .message } " )
324331 return None
325332
333+ def _get_default_catalog_name (self , connection : Connection ) -> Optional [str ]:
334+ dbapi_connection : trino_dbapi .Connection = connection .connection
335+ return dbapi_connection .catalog
336+
326337 def _get_default_schema_name (self , connection : Connection ) -> Optional [str ]:
327338 dbapi_connection : trino_dbapi .Connection = connection .connection
328339 return dbapi_connection .schema
0 commit comments