@@ -229,6 +229,18 @@ def _get_partitions(
229
229
partition_names = [desc [0 ] for desc in res .cursor .description ]
230
230
return partition_names
231
231
232
+ def _get_connector_name (self , connection : Connection , catalog_name : str ):
233
+ query = dedent (
234
+ """
235
+ SELECT
236
+ "connector_name"
237
+ FROM "system"."metadata"."catalogs"
238
+ WHERE "catalog_name" = :catalog_name
239
+ """
240
+ ).strip ()
241
+ res = connection .execute (sql .text (query ), {"catalog_name" : catalog_name })
242
+ return res .scalar ()
243
+
232
244
def get_pk_constraint (self , connection : Connection , table_name : str , schema : str = None , ** kw ) -> Dict [str , Any ]:
233
245
"""Trino has no support for primary keys. Returns a dummy"""
234
246
return dict (name = None , constrained_columns = [])
@@ -322,11 +334,20 @@ def get_indexes(self, connection: Connection, table_name: str, schema: str = Non
322
334
if not self .has_table (connection , table_name , schema ):
323
335
raise exc .NoSuchTableError (f"schema={ schema } , table={ table_name } " )
324
336
337
+ catalog_name = self ._get_default_catalog_name (connection )
338
+ if catalog_name is None :
339
+ raise exc .NoSuchTableError ("catalog is required in connection" )
340
+ connector_name = self ._get_connector_name (connection , catalog_name )
341
+ if connector_name is None :
342
+ raise exc .NoSuchTableError ("connector name is required" )
343
+ if connector_name != "hive" :
344
+ return []
345
+
325
346
partitioned_columns = None
326
347
try :
327
348
partitioned_columns = self ._get_partitions (connection , f"{ table_name } " , schema )
328
349
except Exception as e :
329
- # e.g. it's not a Hive table or an unpartitioned Hive table
350
+ # e.g. it's an unpartitioned Hive table
330
351
logger .debug ("Couldn't fetch partition columns. schema: %s, table: %s, error: %s" , schema , table_name , e )
331
352
if not partitioned_columns :
332
353
return []
0 commit comments