2626from sqlglot .optimizer .qualify_columns import quote_identifiers
2727
2828from sqlmesh .core .dialect import add_table , select_from_values_for_batch_range
29- from sqlmesh .core .engine_adapter .shared import DataObject , TransactionType
29+ from sqlmesh .core .engine_adapter .shared import DataObject
3030from sqlmesh .core .model .kind import TimeColumn
3131from sqlmesh .core .schema_diff import SchemaDiffer
3232from sqlmesh .utils import double_escape
@@ -117,6 +117,7 @@ class EngineAdapter:
117117 DEFAULT_BATCH_SIZE = 10000
118118 DEFAULT_SQL_GEN_KWARGS : t .Dict [str , str | bool | int ] = {}
119119 ESCAPE_JSON = False
120+ SUPPORTS_TRANSACTIONS = True
120121 SUPPORTS_INDEXES = False
121122 INSERT_OVERWRITE_STRATEGY = InsertOverwriteStrategy .DELETE_INSERT
122123 SUPPORTS_MATERIALIZED_VIEWS = False
@@ -538,7 +539,7 @@ def alter_table(
538539 """
539540 Performs the required alter statements to change the current table into the structure of the target table.
540541 """
541- with self .transaction (TransactionType . DDL ):
542+ with self .transaction ():
542543 for alter_expression in self .SCHEMA_DIFFER .compare_columns (
543544 current_table_name ,
544545 self .columns (current_table_name ),
@@ -1216,13 +1217,12 @@ def fetch_pyspark_df(
12161217 @contextlib .contextmanager
12171218 def transaction (
12181219 self ,
1219- transaction_type : TransactionType = TransactionType .DML ,
12201220 condition : t .Optional [bool ] = None ,
12211221 ) -> t .Iterator [None ]:
12221222 """A transaction context manager."""
12231223 if (
12241224 self ._connection_pool .is_transaction_active
1225- or not self .supports_transactions ( transaction_type )
1225+ or not self .SUPPORTS_TRANSACTIONS
12261226 or (condition is not None and not condition )
12271227 ):
12281228 yield
@@ -1236,10 +1236,6 @@ def transaction(
12361236 else :
12371237 self ._connection_pool .commit ()
12381238
1239- def supports_transactions (self , transaction_type : TransactionType ) -> bool :
1240- """Whether or not the engine adapter supports transactions for the given transaction type."""
1241- return True
1242-
12431239 @contextlib .contextmanager
12441240 def session (self ) -> t .Iterator [None ]:
12451241 """A session context manager."""
@@ -1275,14 +1271,15 @@ def execute(
12751271 {"unsupported_level" : ErrorLevel .IGNORE } if ignore_unsupported_errors else {}
12761272 )
12771273
1278- for e in ensure_list (expressions ):
1279- sql = (
1280- self ._to_sql (e , quote = quote_identifiers , ** to_sql_kwargs )
1281- if isinstance (e , exp .Expression )
1282- else e
1283- )
1284- logger .debug (f"Executing SQL:\n { sql } " )
1285- self .cursor .execute (sql , ** kwargs )
1274+ with self .transaction ():
1275+ for e in ensure_list (expressions ):
1276+ sql = (
1277+ self ._to_sql (e , quote = quote_identifiers , ** to_sql_kwargs )
1278+ if isinstance (e , exp .Expression )
1279+ else e
1280+ )
1281+ logger .debug (f"Executing SQL:\n { sql } " )
1282+ self .cursor .execute (sql , ** kwargs )
12861283
12871284 @contextlib .contextmanager
12881285 def temp_table (
@@ -1307,7 +1304,7 @@ def temp_table(
13071304 source_queries , columns_to_types = self ._get_source_queries_and_columns_to_types (
13081305 query_or_df , columns_to_types = columns_to_types , target_table = name
13091306 )
1310- with self .transaction (TransactionType . DDL ):
1307+ with self .transaction ():
13111308 table = self ._get_temp_table (name )
13121309 if table .db :
13131310 self .create_schema (table .db )
0 commit comments