File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed
sqlmesh/core/engine_adapter Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -41,6 +41,10 @@ class AthenaEngineAdapter(PandasNativeFetchDFSupportMixin, RowDiffMixin):
41
41
COMMENT_CREATION_VIEW = CommentCreationView .UNSUPPORTED
42
42
SCHEMA_DIFFER = TrinoEngineAdapter .SCHEMA_DIFFER
43
43
MAX_TIMESTAMP_PRECISION = 3 # copied from Trino
44
+ # Athena does not deal with comments well, e.g:
45
+ # >>> self._execute('/* test */ DESCRIBE foo')
46
+ # pyathena.error.OperationalError: FAILED: ParseException line 1:0 cannot recognize input near '/' '*' 'test'
47
+ ATTACH_CORRELATION_ID = False
44
48
45
49
def __init__ (
46
50
self , * args : t .Any , s3_warehouse_location : t .Optional [str ] = None , ** kwargs : t .Any
Original file line number Diff line number Diff line change @@ -109,6 +109,7 @@ class EngineAdapter:
109
109
DEFAULT_CATALOG_TYPE = DIALECT
110
110
QUOTE_IDENTIFIERS_IN_VIEWS = True
111
111
MAX_IDENTIFIER_LENGTH : t .Optional [int ] = None
112
+ ATTACH_CORRELATION_ID = True
112
113
113
114
def __init__ (
114
115
self ,
@@ -2219,8 +2220,7 @@ def execute(
2219
2220
else :
2220
2221
sql = t .cast (str , e )
2221
2222
2222
- if self .correlation_id :
2223
- sql = f"/* { self .correlation_id } */ { sql } "
2223
+ sql = self ._attach_correlation_id (sql )
2224
2224
2225
2225
self ._log_sql (
2226
2226
sql ,
@@ -2229,6 +2229,11 @@ def execute(
2229
2229
)
2230
2230
self ._execute (sql , ** kwargs )
2231
2231
2232
+ def _attach_correlation_id (self , sql : str ) -> str :
2233
+ if self .ATTACH_CORRELATION_ID and self .correlation_id :
2234
+ return f"/* { self .correlation_id } */ { sql } "
2235
+ return sql
2236
+
2232
2237
def _log_sql (
2233
2238
self ,
2234
2239
sql : str ,
You can’t perform that action at this time.
0 commit comments