32
32
from snowflake .connector .result_set import ResultSet
33
33
34
34
from . import compat
35
+ from ._sql_util import get_file_transfer_type
35
36
from .bind_upload_agent import BindUploadAgent , BindUploadError
36
37
from .constants import (
37
38
FIELD_NAME_TO_ID ,
@@ -183,8 +184,6 @@ class SnowflakeCursor:
183
184
Calling a function is expensive in Python and most of these getters are unnecessary.
184
185
"""
185
186
186
- PUT_SQL_RE = re .compile (r"^(?:/\*.*\*/\s*)*put\s+" , flags = re .IGNORECASE )
187
- GET_SQL_RE = re .compile (r"^(?:/\*.*\*/\s*)*get\s+" , flags = re .IGNORECASE )
188
187
INSERT_SQL_RE = re .compile (r"^insert\s+into" , flags = re .IGNORECASE )
189
188
COMMENT_SQL_RE = re .compile (r"/\*.*\*/" )
190
189
INSERT_SQL_VALUES_RE = re .compile (
@@ -202,11 +201,7 @@ def get_file_transfer_type(sql: str) -> FileTransferType | None:
202
201
None is returned if the SQL isn't a file transfer so that this function can be
203
202
used in an if-statement.
204
203
"""
205
- if SnowflakeCursor .PUT_SQL_RE .match (sql ):
206
- return FileTransferType .PUT
207
- elif SnowflakeCursor .GET_SQL_RE .match (sql ):
208
- return FileTransferType .GET
209
- return None
204
+ return get_file_transfer_type (sql )
210
205
211
206
def __init__ (
212
207
self ,
@@ -464,9 +459,7 @@ def _execute_helper(
464
459
self ._is_file_transfer = _is_put_get
465
460
else :
466
461
# or detect it.
467
- self ._is_file_transfer = self .PUT_SQL_RE .match (
468
- query
469
- ) or self .GET_SQL_RE .match (query )
462
+ self ._is_file_transfer = get_file_transfer_type (query ) is not None
470
463
logger .debug ("is_file_transfer: %s" , self ._is_file_transfer is not None )
471
464
472
465
real_timeout = (
0 commit comments