snowflake-connector-python 4.4.0__cp314-cp314-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- snowflake/connector/__init__.py +118 -0
- snowflake/connector/_query_context_cache.py +276 -0
- snowflake/connector/_sql_util.py +48 -0
- snowflake/connector/_utils.py +353 -0
- snowflake/connector/aio/README.md +88 -0
- snowflake/connector/aio/__init__.py +163 -0
- snowflake/connector/aio/_azure_storage_client.py +227 -0
- snowflake/connector/aio/_bind_upload_agent.py +69 -0
- snowflake/connector/aio/_connection.py +1216 -0
- snowflake/connector/aio/_cursor.py +1402 -0
- snowflake/connector/aio/_description.py +5 -0
- snowflake/connector/aio/_direct_file_operation_utils.py +88 -0
- snowflake/connector/aio/_file_transfer_agent.py +316 -0
- snowflake/connector/aio/_gcs_storage_client.py +360 -0
- snowflake/connector/aio/_network.py +860 -0
- snowflake/connector/aio/_ocsp_asn1crypto.py +51 -0
- snowflake/connector/aio/_ocsp_snowflake.py +608 -0
- snowflake/connector/aio/_pandas_tools.py +561 -0
- snowflake/connector/aio/_result_batch.py +442 -0
- snowflake/connector/aio/_result_set.py +309 -0
- snowflake/connector/aio/_s3_storage_client.py +460 -0
- snowflake/connector/aio/_session_manager.py +588 -0
- snowflake/connector/aio/_storage_client.py +331 -0
- snowflake/connector/aio/_telemetry.py +97 -0
- snowflake/connector/aio/_time_util.py +57 -0
- snowflake/connector/aio/_wif_util.py +324 -0
- snowflake/connector/aio/auth/__init__.py +52 -0
- snowflake/connector/aio/auth/_auth.py +406 -0
- snowflake/connector/aio/auth/_by_plugin.py +131 -0
- snowflake/connector/aio/auth/_default.py +28 -0
- snowflake/connector/aio/auth/_idtoken.py +54 -0
- snowflake/connector/aio/auth/_keypair.py +60 -0
- snowflake/connector/aio/auth/_no_auth.py +31 -0
- snowflake/connector/aio/auth/_oauth.py +27 -0
- snowflake/connector/aio/auth/_oauth_code.py +117 -0
- snowflake/connector/aio/auth/_oauth_credentials.py +100 -0
- snowflake/connector/aio/auth/_okta.py +247 -0
- snowflake/connector/aio/auth/_pat.py +27 -0
- snowflake/connector/aio/auth/_usrpwdmfa.py +30 -0
- snowflake/connector/aio/auth/_webbrowser.py +405 -0
- snowflake/connector/aio/auth/_workload_identity.py +60 -0
- snowflake/connector/arrow_context.py +211 -0
- snowflake/connector/auth/__init__.py +53 -0
- snowflake/connector/auth/_auth.py +669 -0
- snowflake/connector/auth/_http_server.py +257 -0
- snowflake/connector/auth/_oauth_base.py +472 -0
- snowflake/connector/auth/by_plugin.py +219 -0
- snowflake/connector/auth/default.py +36 -0
- snowflake/connector/auth/idtoken.py +72 -0
- snowflake/connector/auth/keypair.py +225 -0
- snowflake/connector/auth/no_auth.py +39 -0
- snowflake/connector/auth/oauth.py +49 -0
- snowflake/connector/auth/oauth_code.py +490 -0
- snowflake/connector/auth/oauth_credentials.py +71 -0
- snowflake/connector/auth/okta.py +339 -0
- snowflake/connector/auth/pat.py +40 -0
- snowflake/connector/auth/usrpwdmfa.py +69 -0
- snowflake/connector/auth/webbrowser.py +514 -0
- snowflake/connector/auth/workload_identity.py +110 -0
- snowflake/connector/azure_storage_client.py +278 -0
- snowflake/connector/backoff_policies.py +141 -0
- snowflake/connector/bind_upload_agent.py +89 -0
- snowflake/connector/cache.py +696 -0
- snowflake/connector/compat.py +127 -0
- snowflake/connector/config_manager.py +553 -0
- snowflake/connector/connection.py +2671 -0
- snowflake/connector/connection_diagnostic.py +793 -0
- snowflake/connector/constants.py +460 -0
- snowflake/connector/converter.py +809 -0
- snowflake/connector/converter_issue23517.py +87 -0
- snowflake/connector/converter_null.py +14 -0
- snowflake/connector/converter_snowsql.py +205 -0
- snowflake/connector/crl.py +919 -0
- snowflake/connector/crl_cache.py +734 -0
- snowflake/connector/cursor.py +2099 -0
- snowflake/connector/dbapi.py +53 -0
- snowflake/connector/description.py +21 -0
- snowflake/connector/direct_file_operation_utils.py +88 -0
- snowflake/connector/encryption_util.py +220 -0
- snowflake/connector/errorcode.py +94 -0
- snowflake/connector/errors.py +666 -0
- snowflake/connector/externals_utils/__init__.py +0 -0
- snowflake/connector/externals_utils/externals_setup.py +30 -0
- snowflake/connector/feature.py +4 -0
- snowflake/connector/file_compression_type.py +118 -0
- snowflake/connector/file_lock.py +72 -0
- snowflake/connector/file_transfer_agent.py +1244 -0
- snowflake/connector/file_util.py +153 -0
- snowflake/connector/gcs_storage_client.py +476 -0
- snowflake/connector/gzip_decoder.py +85 -0
- snowflake/connector/interval_util.py +26 -0
- snowflake/connector/local_storage_client.py +90 -0
- snowflake/connector/log_configuration.py +62 -0
- snowflake/connector/logging_utils/__init__.py +0 -0
- snowflake/connector/logging_utils/filters.py +72 -0
- snowflake/connector/minicore/__init__.py +0 -0
- snowflake/connector/minicore/aix_ppc64/libsf_mini_core.a +0 -0
- snowflake/connector/minicore/aix_ppc64/libsf_mini_core_static.a +0 -0
- snowflake/connector/minicore/linux_aarch64_glibc/libsf_mini_core.so +0 -0
- snowflake/connector/minicore/linux_aarch64_musl/libsf_mini_core.so +0 -0
- snowflake/connector/minicore/linux_x86_64_glibc/libsf_mini_core.so +0 -0
- snowflake/connector/minicore/linux_x86_64_musl/libsf_mini_core.so +0 -0
- snowflake/connector/minicore/macos_aarch64/libsf_mini_core.dylib +0 -0
- snowflake/connector/minicore/macos_x86_64/libsf_mini_core.dylib +0 -0
- snowflake/connector/minicore/windows_x86_64/sf_mini_core.dll +0 -0
- snowflake/connector/minicore/windows_x86_64/sf_mini_core_static.lib +0 -0
- snowflake/connector/nanoarrow_arrow_iterator.cp314-win_amd64.pyd +0 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/ArrayConverter.cpp +60 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/ArrayConverter.hpp +29 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/BinaryConverter.cpp +19 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/BinaryConverter.hpp +26 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/BooleanConverter.cpp +21 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/BooleanConverter.hpp +23 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/CArrowChunkIterator.cpp +570 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/CArrowChunkIterator.hpp +98 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/CArrowIterator.cpp +125 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/CArrowIterator.hpp +115 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/CArrowTableIterator.cpp +1140 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/CArrowTableIterator.hpp +138 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/DateConverter.cpp +47 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/DateConverter.hpp +46 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/DecFloatConverter.cpp +83 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/DecFloatConverter.hpp +35 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/DecimalConverter.cpp +97 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/DecimalConverter.hpp +72 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/FixedSizeListConverter.cpp +73 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/FixedSizeListConverter.hpp +28 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/FloatConverter.cpp +30 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/FloatConverter.hpp +35 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/IColumnConverter.hpp +17 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/IntConverter.cpp +23 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/IntConverter.hpp +45 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/IntervalConverter.cpp +75 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/IntervalConverter.hpp +57 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/LICENSE.txt +209 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/MapConverter.cpp +75 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/MapConverter.hpp +30 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/ObjectConverter.cpp +46 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/ObjectConverter.hpp +29 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/Python/Common.cpp +8 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/Python/Common.hpp +95 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/Python/Helpers.cpp +57 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/Python/Helpers.hpp +36 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/SnowflakeType.cpp +34 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/SnowflakeType.hpp +48 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/StringConverter.cpp +19 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/StringConverter.hpp +26 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/TimeConverter.cpp +36 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/TimeConverter.hpp +31 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/TimeStampConverter.cpp +346 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/TimeStampConverter.hpp +145 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/Util/macros.hpp +14 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/Util/time.cpp +67 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/Util/time.hpp +68 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_accessors.h +101 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_alloc.h +127 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_assert.h +45 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_builder.h +1908 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_emitter.h +215 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_endian.h +125 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_epilogue.h +7 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_flatbuffers.h +55 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_identifier.h +148 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_iov.h +31 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_prologue.h +8 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_refmap.h +144 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_rtconfig.h +162 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_types.h +97 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_verifier.h +239 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/flatcc_portable.h +14 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/paligned_alloc.h +210 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pattributes.h +84 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pdiagnostic.h +84 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pdiagnostic_pop.h +20 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pdiagnostic_push.h +51 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pendian.h +206 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pendian_detect.h +118 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pinline.h +19 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pinttypes.h +52 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/portable.h +2 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/portable_basic.h +25 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pstatic_assert.h +67 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pstdalign.h +162 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pstdint.h +898 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/punaligned.h +190 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pversion.h +6 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pwarnings.h +52 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc.c +3204 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/nanoarrow.c +3217 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/nanoarrow.h +3618 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/nanoarrow.hpp +379 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/nanoarrow_arrow_iterator.pyx +262 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/nanoarrow_device.c +512 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/nanoarrow_device.h +350 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/nanoarrow_ipc.c +33273 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/nanoarrow_ipc.h +397 -0
- snowflake/connector/nanoarrow_cpp/Logging/logging.cpp +100 -0
- snowflake/connector/nanoarrow_cpp/Logging/logging.hpp +49 -0
- snowflake/connector/network.py +1227 -0
- snowflake/connector/ocsp_asn1crypto.py +447 -0
- snowflake/connector/ocsp_snowflake.py +1939 -0
- snowflake/connector/options.py +179 -0
- snowflake/connector/os_details.py +88 -0
- snowflake/connector/pandas_tools.py +734 -0
- snowflake/connector/platform_detection.py +555 -0
- snowflake/connector/proxy.py +28 -0
- snowflake/connector/py.typed +0 -0
- snowflake/connector/result_batch.py +917 -0
- snowflake/connector/result_set.py +340 -0
- snowflake/connector/s3_storage_client.py +614 -0
- snowflake/connector/secret_detector.py +181 -0
- snowflake/connector/session_manager.py +650 -0
- snowflake/connector/sf_dirs.py +64 -0
- snowflake/connector/sfbinaryformat.py +35 -0
- snowflake/connector/sfdatetime.py +345 -0
- snowflake/connector/snow_logging.py +144 -0
- snowflake/connector/sqlstate.py +9 -0
- snowflake/connector/ssd_internal_keys.py +30 -0
- snowflake/connector/ssl_wrap_socket.py +281 -0
- snowflake/connector/storage_client.py +486 -0
- snowflake/connector/telemetry.py +254 -0
- snowflake/connector/telemetry_oob.py +544 -0
- snowflake/connector/test_util.py +30 -0
- snowflake/connector/time_util.py +159 -0
- snowflake/connector/token_cache.py +457 -0
- snowflake/connector/tool/__init__.py +0 -0
- snowflake/connector/tool/dump_certs.py +57 -0
- snowflake/connector/tool/dump_ocsp_response.py +139 -0
- snowflake/connector/tool/dump_ocsp_response_cache.py +194 -0
- snowflake/connector/tool/probe_connection.py +69 -0
- snowflake/connector/url_util.py +55 -0
- snowflake/connector/util_text.py +320 -0
- snowflake/connector/vendored/__init__.py +3 -0
- snowflake/connector/vendored/requests/LICENSE +175 -0
- snowflake/connector/vendored/requests/__init__.py +184 -0
- snowflake/connector/vendored/requests/__version__.py +14 -0
- snowflake/connector/vendored/requests/_internal_utils.py +50 -0
- snowflake/connector/vendored/requests/adapters.py +696 -0
- snowflake/connector/vendored/requests/api.py +157 -0
- snowflake/connector/vendored/requests/auth.py +314 -0
- snowflake/connector/vendored/requests/certs.py +17 -0
- snowflake/connector/vendored/requests/compat.py +106 -0
- snowflake/connector/vendored/requests/cookies.py +561 -0
- snowflake/connector/vendored/requests/exceptions.py +151 -0
- snowflake/connector/vendored/requests/help.py +134 -0
- snowflake/connector/vendored/requests/hooks.py +33 -0
- snowflake/connector/vendored/requests/models.py +1039 -0
- snowflake/connector/vendored/requests/packages.py +23 -0
- snowflake/connector/vendored/requests/sessions.py +831 -0
- snowflake/connector/vendored/requests/status_codes.py +128 -0
- snowflake/connector/vendored/requests/structures.py +99 -0
- snowflake/connector/vendored/requests/utils.py +1086 -0
- snowflake/connector/vendored/urllib3/LICENSE.txt +21 -0
- snowflake/connector/vendored/urllib3/__init__.py +211 -0
- snowflake/connector/vendored/urllib3/_base_connection.py +165 -0
- snowflake/connector/vendored/urllib3/_collections.py +487 -0
- snowflake/connector/vendored/urllib3/_request_methods.py +278 -0
- snowflake/connector/vendored/urllib3/_version.py +34 -0
- snowflake/connector/vendored/urllib3/connection.py +1108 -0
- snowflake/connector/vendored/urllib3/connectionpool.py +1178 -0
- snowflake/connector/vendored/urllib3/contrib/__init__.py +0 -0
- snowflake/connector/vendored/urllib3/contrib/emscripten/__init__.py +17 -0
- snowflake/connector/vendored/urllib3/contrib/emscripten/connection.py +260 -0
- snowflake/connector/vendored/urllib3/contrib/emscripten/emscripten_fetch_worker.js +110 -0
- snowflake/connector/vendored/urllib3/contrib/emscripten/fetch.py +726 -0
- snowflake/connector/vendored/urllib3/contrib/emscripten/request.py +22 -0
- snowflake/connector/vendored/urllib3/contrib/emscripten/response.py +277 -0
- snowflake/connector/vendored/urllib3/contrib/pyopenssl.py +564 -0
- snowflake/connector/vendored/urllib3/contrib/socks.py +228 -0
- snowflake/connector/vendored/urllib3/exceptions.py +335 -0
- snowflake/connector/vendored/urllib3/fields.py +341 -0
- snowflake/connector/vendored/urllib3/filepost.py +89 -0
- snowflake/connector/vendored/urllib3/http2/__init__.py +53 -0
- snowflake/connector/vendored/urllib3/http2/connection.py +356 -0
- snowflake/connector/vendored/urllib3/http2/probe.py +87 -0
- snowflake/connector/vendored/urllib3/poolmanager.py +651 -0
- snowflake/connector/vendored/urllib3/py.typed +2 -0
- snowflake/connector/vendored/urllib3/response.py +1480 -0
- snowflake/connector/vendored/urllib3/util/__init__.py +42 -0
- snowflake/connector/vendored/urllib3/util/connection.py +137 -0
- snowflake/connector/vendored/urllib3/util/proxy.py +43 -0
- snowflake/connector/vendored/urllib3/util/request.py +263 -0
- snowflake/connector/vendored/urllib3/util/response.py +101 -0
- snowflake/connector/vendored/urllib3/util/retry.py +549 -0
- snowflake/connector/vendored/urllib3/util/ssl_.py +527 -0
- snowflake/connector/vendored/urllib3/util/ssl_match_hostname.py +159 -0
- snowflake/connector/vendored/urllib3/util/ssltransport.py +271 -0
- snowflake/connector/vendored/urllib3/util/timeout.py +275 -0
- snowflake/connector/vendored/urllib3/util/url.py +469 -0
- snowflake/connector/vendored/urllib3/util/util.py +42 -0
- snowflake/connector/vendored/urllib3/util/wait.py +124 -0
- snowflake/connector/version.py +3 -0
- snowflake/connector/wif_util.py +434 -0
- snowflake_connector_python-4.4.0.dist-info/DELVEWHEEL +2 -0
- snowflake_connector_python-4.4.0.dist-info/METADATA +1591 -0
- snowflake_connector_python-4.4.0.dist-info/RECORD +302 -0
- snowflake_connector_python-4.4.0.dist-info/WHEEL +5 -0
- snowflake_connector_python-4.4.0.dist-info/entry_points.txt +4 -0
- snowflake_connector_python-4.4.0.dist-info/licenses/LICENSE.txt +202 -0
- snowflake_connector_python-4.4.0.dist-info/licenses/NOTICE +8 -0
- snowflake_connector_python-4.4.0.dist-info/top_level.txt +1 -0
- snowflake_connector_python.libs/msvcp140-0f885b509a685d2bbfa652fed26b5fb3.dll +0 -0
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import TYPE_CHECKING
|
|
4
|
+
|
|
5
|
+
if TYPE_CHECKING:
|
|
6
|
+
from ._connection import SnowflakeConnection
|
|
7
|
+
|
|
8
|
+
import os
|
|
9
|
+
from abc import ABC, abstractmethod
|
|
10
|
+
|
|
11
|
+
from ..constants import CMD_TYPE_UPLOAD
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class FileOperationParserBase(ABC):
|
|
15
|
+
"""The interface of internal utility functions for file operation parsing."""
|
|
16
|
+
|
|
17
|
+
@abstractmethod
|
|
18
|
+
def __init__(self, connection):
|
|
19
|
+
pass
|
|
20
|
+
|
|
21
|
+
@abstractmethod
|
|
22
|
+
async def parse_file_operation(
|
|
23
|
+
self,
|
|
24
|
+
stage_location,
|
|
25
|
+
local_file_name,
|
|
26
|
+
target_directory,
|
|
27
|
+
command_type,
|
|
28
|
+
options,
|
|
29
|
+
has_source_from_stream=False,
|
|
30
|
+
):
|
|
31
|
+
"""Converts the file operation details into a SQL and returns the SQL parsing result."""
|
|
32
|
+
pass
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class StreamDownloaderBase(ABC):
|
|
36
|
+
"""The interface of internal utility functions for stream downloading of file."""
|
|
37
|
+
|
|
38
|
+
@abstractmethod
|
|
39
|
+
def __init__(self, connection):
|
|
40
|
+
pass
|
|
41
|
+
|
|
42
|
+
@abstractmethod
|
|
43
|
+
async def download_as_stream(self, ret, decompress=False):
|
|
44
|
+
pass
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class FileOperationParser(FileOperationParserBase):
|
|
48
|
+
def __init__(self, connection: SnowflakeConnection):
|
|
49
|
+
self._connection = connection
|
|
50
|
+
|
|
51
|
+
async def parse_file_operation(
|
|
52
|
+
self,
|
|
53
|
+
stage_location,
|
|
54
|
+
local_file_name,
|
|
55
|
+
target_directory,
|
|
56
|
+
command_type,
|
|
57
|
+
options,
|
|
58
|
+
has_source_from_stream=False,
|
|
59
|
+
):
|
|
60
|
+
"""Parses a file operation by constructing SQL and getting the SQL parsing result from server."""
|
|
61
|
+
options = options or {}
|
|
62
|
+
options_in_sql = " ".join(f"{k}={v}" for k, v in options.items())
|
|
63
|
+
|
|
64
|
+
if command_type == CMD_TYPE_UPLOAD:
|
|
65
|
+
if has_source_from_stream:
|
|
66
|
+
stage_location, unprefixed_local_file_name = os.path.split(
|
|
67
|
+
stage_location
|
|
68
|
+
)
|
|
69
|
+
local_file_name = "file://" + unprefixed_local_file_name
|
|
70
|
+
sql = f"PUT {local_file_name} ? {options_in_sql}"
|
|
71
|
+
params = [stage_location]
|
|
72
|
+
else:
|
|
73
|
+
raise NotImplementedError(f"unsupported command type: {command_type}")
|
|
74
|
+
|
|
75
|
+
async with self._connection.cursor() as cursor:
|
|
76
|
+
# Send constructed SQL to server and get back parsing result.
|
|
77
|
+
processed_params = cursor._connection._process_params_qmarks(params, cursor)
|
|
78
|
+
return await cursor._execute_helper(
|
|
79
|
+
sql, binding_params=processed_params, is_internal=True
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
class StreamDownloader(StreamDownloaderBase):
|
|
84
|
+
def __init__(self, connection):
|
|
85
|
+
pass
|
|
86
|
+
|
|
87
|
+
async def download_as_stream(self, ret, decompress=False):
|
|
88
|
+
raise NotImplementedError("download_as_stream is not yet supported")
|
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import asyncio
|
|
4
|
+
import os
|
|
5
|
+
import sys
|
|
6
|
+
from logging import getLogger
|
|
7
|
+
from typing import IO, TYPE_CHECKING, Any
|
|
8
|
+
|
|
9
|
+
from ..constants import (
|
|
10
|
+
AZURE_CHUNK_SIZE,
|
|
11
|
+
AZURE_FS,
|
|
12
|
+
CMD_TYPE_DOWNLOAD,
|
|
13
|
+
CMD_TYPE_UPLOAD,
|
|
14
|
+
GCS_FS,
|
|
15
|
+
LOCAL_FS,
|
|
16
|
+
S3_FS,
|
|
17
|
+
ResultStatus,
|
|
18
|
+
megabyte,
|
|
19
|
+
)
|
|
20
|
+
from ..errorcode import ER_FILE_NOT_EXISTS
|
|
21
|
+
from ..errors import Error, OperationalError
|
|
22
|
+
from ..file_transfer_agent import SnowflakeFileMeta
|
|
23
|
+
from ..file_transfer_agent import (
|
|
24
|
+
SnowflakeFileTransferAgent as SnowflakeFileTransferAgentSync,
|
|
25
|
+
)
|
|
26
|
+
from ..file_transfer_agent import SnowflakeProgressPercentage, _chunk_size_calculator
|
|
27
|
+
from ..local_storage_client import SnowflakeLocalStorageClient
|
|
28
|
+
from ._azure_storage_client import SnowflakeAzureRestClient
|
|
29
|
+
from ._gcs_storage_client import SnowflakeGCSRestClient
|
|
30
|
+
from ._s3_storage_client import SnowflakeS3RestClient
|
|
31
|
+
from ._storage_client import SnowflakeStorageClient
|
|
32
|
+
|
|
33
|
+
if TYPE_CHECKING: # pragma: no cover
|
|
34
|
+
from ._cursor import SnowflakeCursor
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
logger = getLogger(__name__)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class SnowflakeFileTransferAgent(SnowflakeFileTransferAgentSync):
|
|
41
|
+
"""Snowflake File Transfer Agent provides cloud provider independent implementation for putting/getting files."""
|
|
42
|
+
|
|
43
|
+
def __init__(
|
|
44
|
+
self,
|
|
45
|
+
cursor: SnowflakeCursor,
|
|
46
|
+
command: str,
|
|
47
|
+
ret: dict[str, Any],
|
|
48
|
+
put_callback: type[SnowflakeProgressPercentage] | None = None,
|
|
49
|
+
put_azure_callback: type[SnowflakeProgressPercentage] | None = None,
|
|
50
|
+
put_callback_output_stream: IO[str] = sys.stdout,
|
|
51
|
+
get_callback: type[SnowflakeProgressPercentage] | None = None,
|
|
52
|
+
get_azure_callback: type[SnowflakeProgressPercentage] | None = None,
|
|
53
|
+
get_callback_output_stream: IO[str] = sys.stdout,
|
|
54
|
+
show_progress_bar: bool = True,
|
|
55
|
+
raise_put_get_error: bool = True,
|
|
56
|
+
force_put_overwrite: bool = True,
|
|
57
|
+
skip_upload_on_content_match: bool = False,
|
|
58
|
+
multipart_threshold: int | None = None,
|
|
59
|
+
source_from_stream: IO[bytes] | None = None,
|
|
60
|
+
use_s3_regional_url: bool = False,
|
|
61
|
+
unsafe_file_write: bool = False,
|
|
62
|
+
reraise_error_in_file_transfer_work_function: bool = False,
|
|
63
|
+
) -> None:
|
|
64
|
+
super().__init__(
|
|
65
|
+
cursor=cursor,
|
|
66
|
+
command=command,
|
|
67
|
+
ret=ret,
|
|
68
|
+
put_callback=put_callback,
|
|
69
|
+
put_azure_callback=put_azure_callback,
|
|
70
|
+
put_callback_output_stream=put_callback_output_stream,
|
|
71
|
+
get_callback=get_callback,
|
|
72
|
+
get_azure_callback=get_azure_callback,
|
|
73
|
+
get_callback_output_stream=get_callback_output_stream,
|
|
74
|
+
show_progress_bar=show_progress_bar,
|
|
75
|
+
raise_put_get_error=raise_put_get_error,
|
|
76
|
+
force_put_overwrite=force_put_overwrite,
|
|
77
|
+
skip_upload_on_content_match=skip_upload_on_content_match,
|
|
78
|
+
multipart_threshold=multipart_threshold,
|
|
79
|
+
source_from_stream=source_from_stream,
|
|
80
|
+
use_s3_regional_url=use_s3_regional_url,
|
|
81
|
+
unsafe_file_write=unsafe_file_write,
|
|
82
|
+
reraise_error_in_file_transfer_work_function=reraise_error_in_file_transfer_work_function,
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
async def execute(self) -> None:
|
|
86
|
+
self._parse_command()
|
|
87
|
+
self._init_file_metadata()
|
|
88
|
+
|
|
89
|
+
if self._command_type == CMD_TYPE_UPLOAD:
|
|
90
|
+
self._process_file_compression_type()
|
|
91
|
+
|
|
92
|
+
for m in self._file_metadata:
|
|
93
|
+
m.sfagent = self
|
|
94
|
+
|
|
95
|
+
await self._transfer_accelerate_config()
|
|
96
|
+
|
|
97
|
+
if self._command_type == CMD_TYPE_DOWNLOAD:
|
|
98
|
+
if not os.path.isdir(self._local_location):
|
|
99
|
+
os.makedirs(self._local_location)
|
|
100
|
+
|
|
101
|
+
if self._stage_location_type == LOCAL_FS:
|
|
102
|
+
if not os.path.isdir(self._stage_info["location"]):
|
|
103
|
+
os.makedirs(self._stage_info["location"])
|
|
104
|
+
|
|
105
|
+
for m in self._file_metadata:
|
|
106
|
+
m.overwrite = self._overwrite
|
|
107
|
+
m.skip_upload_on_content_match = self._skip_upload_on_content_match
|
|
108
|
+
m.sfagent = self
|
|
109
|
+
if self._stage_location_type != LOCAL_FS:
|
|
110
|
+
m.put_callback = self._put_callback
|
|
111
|
+
m.put_azure_callback = self._put_azure_callback
|
|
112
|
+
m.put_callback_output_stream = self._put_callback_output_stream
|
|
113
|
+
m.get_callback = self._get_callback
|
|
114
|
+
m.get_azure_callback = self._get_azure_callback
|
|
115
|
+
m.get_callback_output_stream = self._get_callback_output_stream
|
|
116
|
+
m.show_progress_bar = self._show_progress_bar
|
|
117
|
+
|
|
118
|
+
# multichunk threshold
|
|
119
|
+
m.multipart_threshold = self._multipart_threshold
|
|
120
|
+
|
|
121
|
+
# TODO: SNOW-1625364 for renaming client_prefetch_threads in asyncio
|
|
122
|
+
logger.debug(f"parallel=[{self._parallel}]")
|
|
123
|
+
if self._raise_put_get_error and not self._file_metadata:
|
|
124
|
+
Error.errorhandler_wrapper(
|
|
125
|
+
self._cursor.connection,
|
|
126
|
+
self._cursor,
|
|
127
|
+
OperationalError,
|
|
128
|
+
{
|
|
129
|
+
"msg": "While getting file(s) there was an error: "
|
|
130
|
+
"the file does not exist.",
|
|
131
|
+
"errno": ER_FILE_NOT_EXISTS,
|
|
132
|
+
},
|
|
133
|
+
)
|
|
134
|
+
await self.transfer(self._file_metadata)
|
|
135
|
+
|
|
136
|
+
# turn enum to string, in order to have backward compatible interface
|
|
137
|
+
|
|
138
|
+
for result in self._results:
|
|
139
|
+
result.result_status = result.result_status.value
|
|
140
|
+
|
|
141
|
+
async def transfer(self, metas: list[SnowflakeFileMeta]) -> None:
|
|
142
|
+
files = [await self._create_file_transfer_client(m) for m in metas]
|
|
143
|
+
is_upload = self._command_type == CMD_TYPE_UPLOAD
|
|
144
|
+
finish_download_upload_tasks = []
|
|
145
|
+
|
|
146
|
+
async def preprocess_done_cb(
|
|
147
|
+
success: bool,
|
|
148
|
+
result: Any,
|
|
149
|
+
done_client: SnowflakeStorageClient,
|
|
150
|
+
) -> None:
|
|
151
|
+
if not success:
|
|
152
|
+
logger.debug(f"Failed to prepare {done_client.meta.name}.")
|
|
153
|
+
try:
|
|
154
|
+
if is_upload:
|
|
155
|
+
await done_client.finish_upload()
|
|
156
|
+
done_client.delete_client_data()
|
|
157
|
+
else:
|
|
158
|
+
await done_client.finish_download()
|
|
159
|
+
except Exception as error:
|
|
160
|
+
done_client.meta.error_details = error
|
|
161
|
+
elif done_client.meta.result_status == ResultStatus.SKIPPED:
|
|
162
|
+
# this case applies to upload only
|
|
163
|
+
return
|
|
164
|
+
else:
|
|
165
|
+
try:
|
|
166
|
+
logger.debug(f"Finished preparing file {done_client.meta.name}")
|
|
167
|
+
tasks = []
|
|
168
|
+
for _chunk_id in range(done_client.num_of_chunks):
|
|
169
|
+
task = (
|
|
170
|
+
asyncio.create_task(done_client.upload_chunk(_chunk_id))
|
|
171
|
+
if is_upload
|
|
172
|
+
else asyncio.create_task(
|
|
173
|
+
done_client.download_chunk(_chunk_id)
|
|
174
|
+
)
|
|
175
|
+
)
|
|
176
|
+
task.add_done_callback(
|
|
177
|
+
lambda t, dc=done_client, _chunk_id=_chunk_id: transfer_done_cb(
|
|
178
|
+
t, dc, _chunk_id
|
|
179
|
+
)
|
|
180
|
+
)
|
|
181
|
+
tasks.append(task)
|
|
182
|
+
await asyncio.gather(*tasks)
|
|
183
|
+
await asyncio.gather(*finish_download_upload_tasks)
|
|
184
|
+
except Exception as error:
|
|
185
|
+
done_client.meta.error_details = error
|
|
186
|
+
if self._reraise_error_in_file_transfer_work_function:
|
|
187
|
+
# Propagate task exceptions to the caller to fail the transfer early.
|
|
188
|
+
raise
|
|
189
|
+
|
|
190
|
+
def transfer_done_cb(
|
|
191
|
+
task: asyncio.Task,
|
|
192
|
+
done_client: SnowflakeStorageClient,
|
|
193
|
+
chunk_id: int,
|
|
194
|
+
) -> None:
|
|
195
|
+
# Note: chunk_id is 0 based while num_of_chunks is count
|
|
196
|
+
logger.debug(
|
|
197
|
+
f"Chunk(id: {chunk_id}) {chunk_id+1}/{done_client.num_of_chunks} of file {done_client.meta.name} reached callback"
|
|
198
|
+
)
|
|
199
|
+
if task.exception():
|
|
200
|
+
done_client.failed_transfers += 1
|
|
201
|
+
logger.debug(
|
|
202
|
+
f"Chunk {chunk_id} of file {done_client.meta.name} failed to transfer for unexpected exception {task.exception()}"
|
|
203
|
+
)
|
|
204
|
+
else:
|
|
205
|
+
done_client.successful_transfers += 1
|
|
206
|
+
logger.debug(
|
|
207
|
+
f"Chunk progress: {done_client.meta.name}: completed: {done_client.successful_transfers} failed: {done_client.failed_transfers} total: {done_client.num_of_chunks}"
|
|
208
|
+
)
|
|
209
|
+
if (
|
|
210
|
+
done_client.successful_transfers + done_client.failed_transfers
|
|
211
|
+
== done_client.num_of_chunks
|
|
212
|
+
):
|
|
213
|
+
if is_upload:
|
|
214
|
+
finish_upload_task = asyncio.create_task(
|
|
215
|
+
done_client.finish_upload()
|
|
216
|
+
)
|
|
217
|
+
finish_download_upload_tasks.append(finish_upload_task)
|
|
218
|
+
done_client.delete_client_data()
|
|
219
|
+
else:
|
|
220
|
+
finish_download_task = asyncio.create_task(
|
|
221
|
+
done_client.finish_download()
|
|
222
|
+
)
|
|
223
|
+
finish_download_task.add_done_callback(
|
|
224
|
+
lambda t, dc=done_client: postprocess_done_cb(t, dc)
|
|
225
|
+
)
|
|
226
|
+
finish_download_upload_tasks.append(finish_download_task)
|
|
227
|
+
|
|
228
|
+
def postprocess_done_cb(
|
|
229
|
+
task: asyncio.Task,
|
|
230
|
+
done_client: SnowflakeStorageClient,
|
|
231
|
+
) -> None:
|
|
232
|
+
logger.debug(f"File {done_client.meta.name} reached postprocess callback")
|
|
233
|
+
|
|
234
|
+
if task.exception():
|
|
235
|
+
done_client.failed_transfers += 1
|
|
236
|
+
logger.debug(
|
|
237
|
+
f"File {done_client.meta.name} failed to transfer for unexpected exception {task.exception()}"
|
|
238
|
+
)
|
|
239
|
+
# Whether there was an exception or not, we're done the file.
|
|
240
|
+
|
|
241
|
+
task_of_files = []
|
|
242
|
+
for file_client in files:
|
|
243
|
+
try:
|
|
244
|
+
# TODO: SNOW-1708819 for code refactoring
|
|
245
|
+
res = (
|
|
246
|
+
await file_client.prepare_upload()
|
|
247
|
+
if is_upload
|
|
248
|
+
else await file_client.prepare_download()
|
|
249
|
+
)
|
|
250
|
+
is_successful = True
|
|
251
|
+
except Exception as e:
|
|
252
|
+
res = e
|
|
253
|
+
file_client.meta.error_details = e
|
|
254
|
+
is_successful = False
|
|
255
|
+
|
|
256
|
+
task = asyncio.create_task(
|
|
257
|
+
preprocess_done_cb(is_successful, res, done_client=file_client)
|
|
258
|
+
)
|
|
259
|
+
task_of_files.append(task)
|
|
260
|
+
await asyncio.gather(*task_of_files)
|
|
261
|
+
|
|
262
|
+
self._results = metas
|
|
263
|
+
|
|
264
|
+
async def _transfer_accelerate_config(self) -> None:
|
|
265
|
+
if self._stage_location_type == S3_FS and self._file_metadata:
|
|
266
|
+
client = await self._create_file_transfer_client(self._file_metadata[0])
|
|
267
|
+
self._use_accelerate_endpoint = await client.transfer_accelerate_config()
|
|
268
|
+
|
|
269
|
+
async def _create_file_transfer_client(
|
|
270
|
+
self, meta: SnowflakeFileMeta
|
|
271
|
+
) -> SnowflakeStorageClient:
|
|
272
|
+
if self._stage_location_type == LOCAL_FS:
|
|
273
|
+
return SnowflakeLocalStorageClient(
|
|
274
|
+
meta,
|
|
275
|
+
self._stage_info,
|
|
276
|
+
4 * megabyte,
|
|
277
|
+
unsafe_file_write=self._unsafe_file_write,
|
|
278
|
+
)
|
|
279
|
+
elif self._stage_location_type == AZURE_FS:
|
|
280
|
+
return SnowflakeAzureRestClient(
|
|
281
|
+
meta,
|
|
282
|
+
self._credentials,
|
|
283
|
+
AZURE_CHUNK_SIZE,
|
|
284
|
+
self._stage_info,
|
|
285
|
+
unsafe_file_write=self._unsafe_file_write,
|
|
286
|
+
)
|
|
287
|
+
elif self._stage_location_type == S3_FS:
|
|
288
|
+
client = SnowflakeS3RestClient(
|
|
289
|
+
meta=meta,
|
|
290
|
+
credentials=self._credentials,
|
|
291
|
+
stage_info=self._stage_info,
|
|
292
|
+
chunk_size=_chunk_size_calculator(meta.src_file_size),
|
|
293
|
+
use_accelerate_endpoint=self._use_accelerate_endpoint,
|
|
294
|
+
use_s3_regional_url=self._use_s3_regional_url,
|
|
295
|
+
unsafe_file_write=self._unsafe_file_write,
|
|
296
|
+
)
|
|
297
|
+
await client.transfer_accelerate_config(self._use_accelerate_endpoint)
|
|
298
|
+
return client
|
|
299
|
+
elif self._stage_location_type == GCS_FS:
|
|
300
|
+
client = SnowflakeGCSRestClient(
|
|
301
|
+
meta,
|
|
302
|
+
self._credentials,
|
|
303
|
+
self._stage_info,
|
|
304
|
+
self._cursor._connection,
|
|
305
|
+
self._command,
|
|
306
|
+
unsafe_file_write=self._unsafe_file_write,
|
|
307
|
+
)
|
|
308
|
+
if client.security_token:
|
|
309
|
+
logger.debug(f"len(GCS_ACCESS_TOKEN): {len(client.security_token)}")
|
|
310
|
+
else:
|
|
311
|
+
logger.debug(
|
|
312
|
+
"No access token received from GS, requesting presigned url"
|
|
313
|
+
)
|
|
314
|
+
await client._update_presigned_url()
|
|
315
|
+
return client
|
|
316
|
+
raise Exception(f"{self._stage_location_type} is an unknown stage type")
|