@@ -592,37 +592,9 @@ def _insert_to_table(conn, table_path, values, type):
592592 conn .query (commit )
593593
594594
595- def _create_indexes (conn , table ):
596- # It is unfortunate that Presto doesn't support creating indexes...
597- # Technically we could create it in the backing Postgres behind the scenes.
598- if isinstance (
599- conn , (db .Snowflake , db .Redshift , db .Presto , db .BigQuery , db .Databricks , db .Trino , db .Clickhouse , db .Vertica )
600- ):
601- return
602-
603- try :
604- quote = conn .dialect .quote
605- conn .query (
606- f"CREATE INDEX xa_{ table [1 :- 1 ]} ON { table } ({ quote ('id' )} , { quote ('col' )} )" ,
607- None ,
608- )
609- conn .query (
610- f"CREATE INDEX xb_{ table [1 :- 1 ]} ON { table } ({ quote ('id' )} )" ,
611- None ,
612- )
613- except Exception as err :
614- if "Duplicate key name" in str (err ): # mysql
615- pass
616- elif "such column list already indexed" in str (err ): # oracle
617- pass
618- elif "name is already used" in str (err ): # oracle
619- pass
620- else :
621- raise (err )
622-
623-
624595def _create_table_with_indexes (conn , table_path , type_ ):
625- table_name = "." .join (map (conn .dialect .quote , table_path ))
596+ quote = conn .dialect .quote
597+ table_name = "." .join (map (quote , table_path ))
626598
627599 tbl = table (
628600 table_path ,
@@ -637,7 +609,11 @@ def _create_table_with_indexes(conn, table_path, type_):
637609 else :
638610 conn .query (tbl .create ())
639611
640- _create_indexes (conn , table_name )
612+ if conn .dialect .SUPPORTS_INDEXES :
613+ index_id ,= table_path
614+ conn .query (f"CREATE INDEX xa_{ index_id } ON { table_name } ({ quote ('id' )} , { quote ('col' )} )" )
615+ conn .query (f"CREATE INDEX xb_{ index_id } ON { table_name } ({ quote ('id' )} )" )
616+
641617 conn .query (commit )
642618
643619
0 commit comments