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,87 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
from datetime import datetime, time, timedelta, timezone, tzinfo
|
|
5
|
+
from functools import partial
|
|
6
|
+
from logging import getLogger
|
|
7
|
+
|
|
8
|
+
import pytz
|
|
9
|
+
|
|
10
|
+
from .converter import ZERO_EPOCH, SnowflakeConverter, _generate_tzinfo_from_tzoffset
|
|
11
|
+
|
|
12
|
+
logger = getLogger(__name__)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class SnowflakeConverterIssue23517(SnowflakeConverter):
|
|
16
|
+
"""Converter for Python 3.5.0 or Any Python on Windows.
|
|
17
|
+
|
|
18
|
+
This is to address http://bugs.python.org/issue23517
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
def __init__(self, **kwargs) -> None:
|
|
22
|
+
super().__init__(**kwargs)
|
|
23
|
+
logger.debug("initialized")
|
|
24
|
+
|
|
25
|
+
def _TIMESTAMP_TZ_to_python(self, ctx):
|
|
26
|
+
scale = ctx["scale"]
|
|
27
|
+
|
|
28
|
+
def conv(encoded_value: str) -> datetime:
|
|
29
|
+
value, tz = encoded_value.split()
|
|
30
|
+
tzinfo = _generate_tzinfo_from_tzoffset(int(tz) - 1440)
|
|
31
|
+
return SnowflakeConverterIssue23517.create_timestamp_from_string(
|
|
32
|
+
value=value, scale=scale, tz=tzinfo
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
return conv
|
|
36
|
+
|
|
37
|
+
def _TIMESTAMP_LTZ_to_python(self, ctx):
|
|
38
|
+
tzinfo = self._get_session_tz()
|
|
39
|
+
scale = ctx["scale"]
|
|
40
|
+
|
|
41
|
+
def conv(value: str) -> datetime:
|
|
42
|
+
ts = SnowflakeConverterIssue23517.create_timestamp_from_string(
|
|
43
|
+
value=value, scale=scale
|
|
44
|
+
)
|
|
45
|
+
return pytz.utc.localize(ts, is_dst=False).astimezone(tzinfo)
|
|
46
|
+
|
|
47
|
+
return conv
|
|
48
|
+
|
|
49
|
+
def _TIMESTAMP_NTZ_to_python(self, ctx):
|
|
50
|
+
scale = ctx["scale"]
|
|
51
|
+
return partial(
|
|
52
|
+
SnowflakeConverterIssue23517.create_timestamp_from_string, scale=scale
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
def _TIME_to_python(self, ctx):
|
|
56
|
+
"""Converts TIME to formatted string, SnowflakeDateTime, or datetime.time.
|
|
57
|
+
|
|
58
|
+
No timezone is attached.
|
|
59
|
+
"""
|
|
60
|
+
scale = ctx["scale"]
|
|
61
|
+
|
|
62
|
+
def conv0(value: str) -> time:
|
|
63
|
+
return (ZERO_EPOCH + timedelta(seconds=(float(value)))).time()
|
|
64
|
+
|
|
65
|
+
def conv(value: str) -> time:
|
|
66
|
+
microseconds = float(value[0 : -scale + 6])
|
|
67
|
+
return (ZERO_EPOCH + timedelta(seconds=(microseconds))).time()
|
|
68
|
+
|
|
69
|
+
return conv if scale > 6 else conv0
|
|
70
|
+
|
|
71
|
+
@staticmethod
|
|
72
|
+
def create_timestamp_from_string(
|
|
73
|
+
value: str,
|
|
74
|
+
scale: int,
|
|
75
|
+
tz: tzinfo | None = None,
|
|
76
|
+
) -> datetime:
|
|
77
|
+
"""Windows does not support negative timestamps, so we need to do that part in Python."""
|
|
78
|
+
seconds, fraction = SnowflakeConverter.get_seconds_microseconds(
|
|
79
|
+
value=value, scale=scale
|
|
80
|
+
)
|
|
81
|
+
if not tz:
|
|
82
|
+
return datetime.fromtimestamp(0, timezone.utc).replace(
|
|
83
|
+
tzinfo=None
|
|
84
|
+
) + timedelta(seconds=seconds, microseconds=fraction)
|
|
85
|
+
return datetime.fromtimestamp(0, tz=tz) + timedelta(
|
|
86
|
+
seconds=seconds, microseconds=fraction
|
|
87
|
+
)
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
from typing import Any
|
|
5
|
+
|
|
6
|
+
from .converter import SnowflakeConverter
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class SnowflakeNoConverterToPython(SnowflakeConverter):
|
|
10
|
+
def __init__(self, **kwargs) -> None:
|
|
11
|
+
super().__init__(**kwargs)
|
|
12
|
+
|
|
13
|
+
def to_python_method(self, type_name: str, column: dict[str, Any]) -> None:
|
|
14
|
+
return None
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
import time
|
|
5
|
+
from datetime import date, datetime, timedelta
|
|
6
|
+
from logging import getLogger
|
|
7
|
+
from time import struct_time
|
|
8
|
+
from typing import Any, Callable
|
|
9
|
+
|
|
10
|
+
import pytz
|
|
11
|
+
|
|
12
|
+
from .compat import IS_WINDOWS
|
|
13
|
+
from .constants import is_date_type_name, is_timestamp_type_name
|
|
14
|
+
from .converter import (
|
|
15
|
+
ZERO_EPOCH,
|
|
16
|
+
SnowflakeConverter,
|
|
17
|
+
_adjust_fraction_of_nanoseconds,
|
|
18
|
+
_extract_timestamp,
|
|
19
|
+
_generate_tzinfo_from_tzoffset,
|
|
20
|
+
)
|
|
21
|
+
from .sfbinaryformat import SnowflakeBinaryFormat, binary_to_python
|
|
22
|
+
from .sfdatetime import SnowflakeDateFormat, SnowflakeDateTime, SnowflakeDateTimeFormat
|
|
23
|
+
|
|
24
|
+
logger = getLogger(__name__)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def format_sftimestamp(
|
|
28
|
+
ctx: dict[str, Any], value: datetime | struct_time, franction_of_nanoseconds: int
|
|
29
|
+
) -> str:
|
|
30
|
+
sf_datetime = SnowflakeDateTime(
|
|
31
|
+
datetime=value, nanosecond=franction_of_nanoseconds, scale=ctx.get("scale")
|
|
32
|
+
)
|
|
33
|
+
return ctx["fmt"].format(sf_datetime) if ctx.get("fmt") else str(sf_datetime)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class SnowflakeConverterSnowSQL(SnowflakeConverter):
|
|
37
|
+
"""Snowflake Converter for SnowSQL.
|
|
38
|
+
|
|
39
|
+
Format data instead of just converting the values into native
|
|
40
|
+
Python objects.
|
|
41
|
+
"""
|
|
42
|
+
|
|
43
|
+
def __init__(self, **kwargs) -> None:
|
|
44
|
+
super().__init__(**kwargs)
|
|
45
|
+
self._support_negative_year = kwargs.get("support_negative_year", True)
|
|
46
|
+
|
|
47
|
+
def _get_format(self, type_name: str) -> str:
|
|
48
|
+
"""Gets the format."""
|
|
49
|
+
fmt = None
|
|
50
|
+
if type_name == "DATE":
|
|
51
|
+
fmt = self._parameters.get("DATE_OUTPUT_FORMAT")
|
|
52
|
+
if not fmt:
|
|
53
|
+
fmt = "YYYY-MM-DD"
|
|
54
|
+
elif type_name == "TIME":
|
|
55
|
+
fmt = self._parameters.get("TIME_OUTPUT_FORMAT")
|
|
56
|
+
elif type_name + "_OUTPUT_FORMAT" in self._parameters:
|
|
57
|
+
fmt = self._parameters[type_name + "_OUTPUT_FORMAT"]
|
|
58
|
+
if not fmt:
|
|
59
|
+
fmt = self._parameters["TIMESTAMP_OUTPUT_FORMAT"]
|
|
60
|
+
elif type_name == "BINARY":
|
|
61
|
+
fmt = self._parameters.get("BINARY_OUTPUT_FORMAT")
|
|
62
|
+
return fmt
|
|
63
|
+
|
|
64
|
+
#
|
|
65
|
+
# FROM Snowflake to Python objects
|
|
66
|
+
#
|
|
67
|
+
# Note: Callable doesn't implement operator|
|
|
68
|
+
def to_python_method(
|
|
69
|
+
self, type_name: str, column: dict[str, Any]
|
|
70
|
+
) -> Callable | None:
|
|
71
|
+
ctx = column.copy()
|
|
72
|
+
if ctx.get("scale") is not None:
|
|
73
|
+
ctx["max_fraction"] = int(10 ** ctx["scale"])
|
|
74
|
+
ctx["zero_fill"] = "0" * (9 - ctx["scale"])
|
|
75
|
+
fmt = None
|
|
76
|
+
if is_date_type_name(type_name):
|
|
77
|
+
datetime_class = time.struct_time if not IS_WINDOWS else date
|
|
78
|
+
fmt = SnowflakeDateFormat(
|
|
79
|
+
self._get_format(type_name),
|
|
80
|
+
support_negative_year=self._support_negative_year,
|
|
81
|
+
datetime_class=datetime_class,
|
|
82
|
+
)
|
|
83
|
+
elif is_timestamp_type_name(type_name):
|
|
84
|
+
fmt = SnowflakeDateTimeFormat(
|
|
85
|
+
self._get_format(type_name),
|
|
86
|
+
data_type=type_name,
|
|
87
|
+
support_negative_year=self._support_negative_year,
|
|
88
|
+
datetime_class=SnowflakeDateTime,
|
|
89
|
+
)
|
|
90
|
+
elif type_name == "BINARY":
|
|
91
|
+
fmt = SnowflakeBinaryFormat(self._get_format(type_name))
|
|
92
|
+
logger.debug("Type: %s, Format: %s", type_name, fmt)
|
|
93
|
+
ctx["fmt"] = fmt
|
|
94
|
+
converters = [f"_{type_name}_to_python"]
|
|
95
|
+
for conv in converters:
|
|
96
|
+
try:
|
|
97
|
+
return getattr(self, conv)(ctx)
|
|
98
|
+
except AttributeError:
|
|
99
|
+
pass
|
|
100
|
+
logger.warning("No column converter found for type: %s", type_name)
|
|
101
|
+
return None # Skip conversion
|
|
102
|
+
|
|
103
|
+
def _BOOLEAN_to_python(self, ctx):
|
|
104
|
+
"""No conversion for SnowSQL."""
|
|
105
|
+
return lambda value: "True" if value in ("1", "True") else "False"
|
|
106
|
+
|
|
107
|
+
def _FIXED_to_python(self, ctx):
|
|
108
|
+
"""No conversion for SnowSQL."""
|
|
109
|
+
return None
|
|
110
|
+
|
|
111
|
+
def _REAL_to_python(self, ctx):
|
|
112
|
+
"""No conversion for SnowSQL."""
|
|
113
|
+
return None
|
|
114
|
+
|
|
115
|
+
def _BINARY_to_python(self, ctx):
|
|
116
|
+
"""BINARY to a string formatted by BINARY_OUTPUT_FORMAT."""
|
|
117
|
+
return lambda value: ctx["fmt"].format(binary_to_python(value))
|
|
118
|
+
|
|
119
|
+
def _DATE_to_python(self, ctx: dict[str, str | None]) -> Callable:
|
|
120
|
+
"""Converts DATE to struct_time/date.
|
|
121
|
+
|
|
122
|
+
No timezone is attached.
|
|
123
|
+
"""
|
|
124
|
+
|
|
125
|
+
def conv(value: str) -> str:
|
|
126
|
+
return ctx["fmt"].format(time.gmtime(int(value) * (24 * 60 * 60)))
|
|
127
|
+
|
|
128
|
+
def conv_windows(value):
|
|
129
|
+
ts = ZERO_EPOCH + timedelta(seconds=int(value) * (24 * 60 * 60))
|
|
130
|
+
return ctx["fmt"].format(date(ts.year, ts.month, ts.day))
|
|
131
|
+
|
|
132
|
+
return conv if not IS_WINDOWS else conv_windows
|
|
133
|
+
|
|
134
|
+
def _TIMESTAMP_TZ_to_python(self, ctx: dict[str, Any]) -> Callable:
|
|
135
|
+
"""Converts TIMESTAMP TZ to datetime.
|
|
136
|
+
|
|
137
|
+
The timezone offset is piggybacked.
|
|
138
|
+
"""
|
|
139
|
+
scale = ctx["scale"]
|
|
140
|
+
max_fraction = ctx.get("max_fraction")
|
|
141
|
+
|
|
142
|
+
def conv0(encoded_value: str) -> str:
|
|
143
|
+
value, tz = encoded_value.split()
|
|
144
|
+
microseconds = float(value)
|
|
145
|
+
tzinfo = _generate_tzinfo_from_tzoffset(int(tz) - 1440)
|
|
146
|
+
try:
|
|
147
|
+
t = datetime.fromtimestamp(microseconds, tz=tzinfo)
|
|
148
|
+
except OSError as e:
|
|
149
|
+
logger.debug("OSError occurred but falling back to datetime: %s", e)
|
|
150
|
+
t = ZERO_EPOCH + timedelta(seconds=microseconds)
|
|
151
|
+
if pytz.utc != tzinfo:
|
|
152
|
+
t += tzinfo.utcoffset(t)
|
|
153
|
+
t = t.replace(tzinfo=tzinfo)
|
|
154
|
+
fraction_of_nanoseconds = _adjust_fraction_of_nanoseconds(
|
|
155
|
+
value, max_fraction, scale
|
|
156
|
+
)
|
|
157
|
+
|
|
158
|
+
return format_sftimestamp(ctx, t, fraction_of_nanoseconds)
|
|
159
|
+
|
|
160
|
+
def conv(encoded_value: str) -> str:
|
|
161
|
+
value, tz = encoded_value.split()
|
|
162
|
+
microseconds = float(value[0 : -scale + 6])
|
|
163
|
+
tzinfo = _generate_tzinfo_from_tzoffset(int(tz) - 1440)
|
|
164
|
+
try:
|
|
165
|
+
t = datetime.fromtimestamp(microseconds, tz=tzinfo)
|
|
166
|
+
except (OSError, ValueError) as e:
|
|
167
|
+
logger.debug("OSError occurred but falling back to datetime: %s", e)
|
|
168
|
+
t = ZERO_EPOCH + timedelta(seconds=microseconds)
|
|
169
|
+
if pytz.utc != tzinfo:
|
|
170
|
+
t += tzinfo.utcoffset(t)
|
|
171
|
+
t = t.replace(tzinfo=tzinfo)
|
|
172
|
+
|
|
173
|
+
fraction_of_nanoseconds = _adjust_fraction_of_nanoseconds(
|
|
174
|
+
value, max_fraction, scale
|
|
175
|
+
)
|
|
176
|
+
|
|
177
|
+
return format_sftimestamp(ctx, t, fraction_of_nanoseconds)
|
|
178
|
+
|
|
179
|
+
return conv if scale > 6 else conv0
|
|
180
|
+
|
|
181
|
+
def _TIMESTAMP_LTZ_to_python(self, ctx: dict[str, Any]) -> Callable:
|
|
182
|
+
def conv(value: str) -> str:
|
|
183
|
+
t, fraction_of_nanoseconds = self._pre_TIMESTAMP_LTZ_to_python(value, ctx)
|
|
184
|
+
return format_sftimestamp(ctx, t, fraction_of_nanoseconds)
|
|
185
|
+
|
|
186
|
+
return conv
|
|
187
|
+
|
|
188
|
+
def _TIMESTAMP_NTZ_to_python(self, ctx: dict[str, Any]) -> Callable:
|
|
189
|
+
"""Converts TIMESTAMP NTZ to Snowflake Formatted String.
|
|
190
|
+
|
|
191
|
+
No timezone info is attached.
|
|
192
|
+
"""
|
|
193
|
+
|
|
194
|
+
def conv(value: str) -> str:
|
|
195
|
+
microseconds, fraction_of_nanoseconds = _extract_timestamp(value, ctx)
|
|
196
|
+
try:
|
|
197
|
+
t = time.gmtime(microseconds)
|
|
198
|
+
except (OSError, ValueError) as e:
|
|
199
|
+
logger.debug("OSError occurred but falling back to datetime: %s", e)
|
|
200
|
+
t = ZERO_EPOCH + timedelta(seconds=(microseconds))
|
|
201
|
+
return format_sftimestamp(ctx, t, fraction_of_nanoseconds)
|
|
202
|
+
|
|
203
|
+
return conv
|
|
204
|
+
|
|
205
|
+
_TIME_to_python = _TIMESTAMP_NTZ_to_python
|