snowflake-connector-python 3.16.0__cp313-cp313-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.
Files changed (246) hide show
  1. snowflake/connector/__init__.py +96 -0
  2. snowflake/connector/_query_context_cache.py +276 -0
  3. snowflake/connector/_sql_util.py +48 -0
  4. snowflake/connector/_utils.py +70 -0
  5. snowflake/connector/arrow_context.py +203 -0
  6. snowflake/connector/auth/__init__.py +53 -0
  7. snowflake/connector/auth/_auth.py +586 -0
  8. snowflake/connector/auth/_http_server.py +220 -0
  9. snowflake/connector/auth/_oauth_base.py +400 -0
  10. snowflake/connector/auth/by_plugin.py +219 -0
  11. snowflake/connector/auth/default.py +36 -0
  12. snowflake/connector/auth/idtoken.py +72 -0
  13. snowflake/connector/auth/keypair.py +222 -0
  14. snowflake/connector/auth/no_auth.py +39 -0
  15. snowflake/connector/auth/oauth.py +49 -0
  16. snowflake/connector/auth/oauth_code.py +479 -0
  17. snowflake/connector/auth/oauth_credentials.py +66 -0
  18. snowflake/connector/auth/okta.py +335 -0
  19. snowflake/connector/auth/pat.py +39 -0
  20. snowflake/connector/auth/usrpwdmfa.py +69 -0
  21. snowflake/connector/auth/webbrowser.py +502 -0
  22. snowflake/connector/auth/workload_identity.py +94 -0
  23. snowflake/connector/azure_storage_client.py +276 -0
  24. snowflake/connector/backoff_policies.py +141 -0
  25. snowflake/connector/bind_upload_agent.py +89 -0
  26. snowflake/connector/cache.py +696 -0
  27. snowflake/connector/compat.py +127 -0
  28. snowflake/connector/config_manager.py +496 -0
  29. snowflake/connector/connection.py +2273 -0
  30. snowflake/connector/connection_diagnostic.py +776 -0
  31. snowflake/connector/constants.py +442 -0
  32. snowflake/connector/converter.py +785 -0
  33. snowflake/connector/converter_issue23517.py +87 -0
  34. snowflake/connector/converter_null.py +14 -0
  35. snowflake/connector/converter_snowsql.py +205 -0
  36. snowflake/connector/cursor.py +1951 -0
  37. snowflake/connector/dbapi.py +53 -0
  38. snowflake/connector/description.py +19 -0
  39. snowflake/connector/direct_file_operation_utils.py +88 -0
  40. snowflake/connector/encryption_util.py +220 -0
  41. snowflake/connector/errorcode.py +91 -0
  42. snowflake/connector/errors.py +615 -0
  43. snowflake/connector/externals_utils/__init__.py +0 -0
  44. snowflake/connector/externals_utils/externals_setup.py +27 -0
  45. snowflake/connector/feature.py +4 -0
  46. snowflake/connector/file_compression_type.py +118 -0
  47. snowflake/connector/file_lock.py +72 -0
  48. snowflake/connector/file_transfer_agent.py +1215 -0
  49. snowflake/connector/file_util.py +153 -0
  50. snowflake/connector/gcs_storage_client.py +474 -0
  51. snowflake/connector/gzip_decoder.py +85 -0
  52. snowflake/connector/local_storage_client.py +90 -0
  53. snowflake/connector/log_configuration.py +60 -0
  54. snowflake/connector/logging_utils/__init__.py +0 -0
  55. snowflake/connector/logging_utils/filters.py +72 -0
  56. snowflake/connector/nanoarrow_arrow_iterator.cp313-win_amd64.pyd +0 -0
  57. snowflake/connector/nanoarrow_cpp/ArrowIterator/ArrayConverter.cpp +60 -0
  58. snowflake/connector/nanoarrow_cpp/ArrowIterator/ArrayConverter.hpp +29 -0
  59. snowflake/connector/nanoarrow_cpp/ArrowIterator/BinaryConverter.cpp +19 -0
  60. snowflake/connector/nanoarrow_cpp/ArrowIterator/BinaryConverter.hpp +26 -0
  61. snowflake/connector/nanoarrow_cpp/ArrowIterator/BooleanConverter.cpp +21 -0
  62. snowflake/connector/nanoarrow_cpp/ArrowIterator/BooleanConverter.hpp +23 -0
  63. snowflake/connector/nanoarrow_cpp/ArrowIterator/CArrowChunkIterator.cpp +557 -0
  64. snowflake/connector/nanoarrow_cpp/ArrowIterator/CArrowChunkIterator.hpp +98 -0
  65. snowflake/connector/nanoarrow_cpp/ArrowIterator/CArrowIterator.cpp +125 -0
  66. snowflake/connector/nanoarrow_cpp/ArrowIterator/CArrowIterator.hpp +115 -0
  67. snowflake/connector/nanoarrow_cpp/ArrowIterator/CArrowTableIterator.cpp +1005 -0
  68. snowflake/connector/nanoarrow_cpp/ArrowIterator/CArrowTableIterator.hpp +127 -0
  69. snowflake/connector/nanoarrow_cpp/ArrowIterator/DateConverter.cpp +47 -0
  70. snowflake/connector/nanoarrow_cpp/ArrowIterator/DateConverter.hpp +46 -0
  71. snowflake/connector/nanoarrow_cpp/ArrowIterator/DecFloatConverter.cpp +83 -0
  72. snowflake/connector/nanoarrow_cpp/ArrowIterator/DecFloatConverter.hpp +35 -0
  73. snowflake/connector/nanoarrow_cpp/ArrowIterator/DecimalConverter.cpp +97 -0
  74. snowflake/connector/nanoarrow_cpp/ArrowIterator/DecimalConverter.hpp +72 -0
  75. snowflake/connector/nanoarrow_cpp/ArrowIterator/FixedSizeListConverter.cpp +73 -0
  76. snowflake/connector/nanoarrow_cpp/ArrowIterator/FixedSizeListConverter.hpp +28 -0
  77. snowflake/connector/nanoarrow_cpp/ArrowIterator/FloatConverter.cpp +30 -0
  78. snowflake/connector/nanoarrow_cpp/ArrowIterator/FloatConverter.hpp +35 -0
  79. snowflake/connector/nanoarrow_cpp/ArrowIterator/IColumnConverter.hpp +17 -0
  80. snowflake/connector/nanoarrow_cpp/ArrowIterator/IntConverter.cpp +23 -0
  81. snowflake/connector/nanoarrow_cpp/ArrowIterator/IntConverter.hpp +45 -0
  82. snowflake/connector/nanoarrow_cpp/ArrowIterator/IntervalConverter.cpp +71 -0
  83. snowflake/connector/nanoarrow_cpp/ArrowIterator/IntervalConverter.hpp +56 -0
  84. snowflake/connector/nanoarrow_cpp/ArrowIterator/LICENSE.txt +209 -0
  85. snowflake/connector/nanoarrow_cpp/ArrowIterator/MapConverter.cpp +75 -0
  86. snowflake/connector/nanoarrow_cpp/ArrowIterator/MapConverter.hpp +30 -0
  87. snowflake/connector/nanoarrow_cpp/ArrowIterator/ObjectConverter.cpp +46 -0
  88. snowflake/connector/nanoarrow_cpp/ArrowIterator/ObjectConverter.hpp +29 -0
  89. snowflake/connector/nanoarrow_cpp/ArrowIterator/Python/Common.cpp +8 -0
  90. snowflake/connector/nanoarrow_cpp/ArrowIterator/Python/Common.hpp +95 -0
  91. snowflake/connector/nanoarrow_cpp/ArrowIterator/Python/Helpers.cpp +57 -0
  92. snowflake/connector/nanoarrow_cpp/ArrowIterator/Python/Helpers.hpp +36 -0
  93. snowflake/connector/nanoarrow_cpp/ArrowIterator/SnowflakeType.cpp +34 -0
  94. snowflake/connector/nanoarrow_cpp/ArrowIterator/SnowflakeType.hpp +48 -0
  95. snowflake/connector/nanoarrow_cpp/ArrowIterator/StringConverter.cpp +19 -0
  96. snowflake/connector/nanoarrow_cpp/ArrowIterator/StringConverter.hpp +26 -0
  97. snowflake/connector/nanoarrow_cpp/ArrowIterator/TimeConverter.cpp +36 -0
  98. snowflake/connector/nanoarrow_cpp/ArrowIterator/TimeConverter.hpp +31 -0
  99. snowflake/connector/nanoarrow_cpp/ArrowIterator/TimeStampConverter.cpp +346 -0
  100. snowflake/connector/nanoarrow_cpp/ArrowIterator/TimeStampConverter.hpp +145 -0
  101. snowflake/connector/nanoarrow_cpp/ArrowIterator/Util/macros.hpp +14 -0
  102. snowflake/connector/nanoarrow_cpp/ArrowIterator/Util/time.cpp +65 -0
  103. snowflake/connector/nanoarrow_cpp/ArrowIterator/Util/time.hpp +68 -0
  104. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_accessors.h +101 -0
  105. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_alloc.h +127 -0
  106. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_assert.h +45 -0
  107. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_builder.h +1908 -0
  108. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_emitter.h +215 -0
  109. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_endian.h +125 -0
  110. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_epilogue.h +7 -0
  111. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_flatbuffers.h +55 -0
  112. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_identifier.h +148 -0
  113. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_iov.h +31 -0
  114. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_prologue.h +8 -0
  115. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_refmap.h +144 -0
  116. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_rtconfig.h +162 -0
  117. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_types.h +97 -0
  118. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_verifier.h +239 -0
  119. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/flatcc_portable.h +14 -0
  120. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/paligned_alloc.h +210 -0
  121. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pattributes.h +84 -0
  122. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pdiagnostic.h +84 -0
  123. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pdiagnostic_pop.h +20 -0
  124. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pdiagnostic_push.h +51 -0
  125. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pendian.h +206 -0
  126. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pendian_detect.h +118 -0
  127. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pinline.h +19 -0
  128. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pinttypes.h +52 -0
  129. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/portable.h +2 -0
  130. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/portable_basic.h +25 -0
  131. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pstatic_assert.h +67 -0
  132. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pstdalign.h +162 -0
  133. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pstdint.h +898 -0
  134. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/punaligned.h +190 -0
  135. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pversion.h +6 -0
  136. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pwarnings.h +52 -0
  137. snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc.c +3204 -0
  138. snowflake/connector/nanoarrow_cpp/ArrowIterator/nanoarrow.c +3217 -0
  139. snowflake/connector/nanoarrow_cpp/ArrowIterator/nanoarrow.h +3618 -0
  140. snowflake/connector/nanoarrow_cpp/ArrowIterator/nanoarrow.hpp +379 -0
  141. snowflake/connector/nanoarrow_cpp/ArrowIterator/nanoarrow_arrow_iterator.pyx +256 -0
  142. snowflake/connector/nanoarrow_cpp/ArrowIterator/nanoarrow_device.c +512 -0
  143. snowflake/connector/nanoarrow_cpp/ArrowIterator/nanoarrow_device.h +350 -0
  144. snowflake/connector/nanoarrow_cpp/ArrowIterator/nanoarrow_ipc.c +33273 -0
  145. snowflake/connector/nanoarrow_cpp/ArrowIterator/nanoarrow_ipc.h +397 -0
  146. snowflake/connector/nanoarrow_cpp/Logging/logging.cpp +100 -0
  147. snowflake/connector/nanoarrow_cpp/Logging/logging.hpp +49 -0
  148. snowflake/connector/network.py +1297 -0
  149. snowflake/connector/ocsp_asn1crypto.py +447 -0
  150. snowflake/connector/ocsp_snowflake.py +1883 -0
  151. snowflake/connector/options.py +131 -0
  152. snowflake/connector/pandas_tools.py +732 -0
  153. snowflake/connector/proxy.py +43 -0
  154. snowflake/connector/py.typed +0 -0
  155. snowflake/connector/result_batch.py +786 -0
  156. snowflake/connector/result_set.py +319 -0
  157. snowflake/connector/s3_storage_client.py +605 -0
  158. snowflake/connector/secret_detector.py +181 -0
  159. snowflake/connector/sf_dirs.py +64 -0
  160. snowflake/connector/sfbinaryformat.py +35 -0
  161. snowflake/connector/sfdatetime.py +345 -0
  162. snowflake/connector/snow_logging.py +144 -0
  163. snowflake/connector/sqlstate.py +9 -0
  164. snowflake/connector/ssd_internal_keys.py +30 -0
  165. snowflake/connector/ssl_wrap_socket.py +134 -0
  166. snowflake/connector/storage_client.py +478 -0
  167. snowflake/connector/telemetry.py +249 -0
  168. snowflake/connector/telemetry_oob.py +543 -0
  169. snowflake/connector/test_util.py +30 -0
  170. snowflake/connector/time_util.py +159 -0
  171. snowflake/connector/token_cache.py +402 -0
  172. snowflake/connector/tool/__init__.py +0 -0
  173. snowflake/connector/tool/dump_certs.py +57 -0
  174. snowflake/connector/tool/dump_ocsp_response.py +139 -0
  175. snowflake/connector/tool/dump_ocsp_response_cache.py +194 -0
  176. snowflake/connector/tool/probe_connection.py +69 -0
  177. snowflake/connector/url_util.py +49 -0
  178. snowflake/connector/util_text.py +301 -0
  179. snowflake/connector/vendored/__init__.py +3 -0
  180. snowflake/connector/vendored/requests/LICENSE +175 -0
  181. snowflake/connector/vendored/requests/__init__.py +169 -0
  182. snowflake/connector/vendored/requests/__version__.py +14 -0
  183. snowflake/connector/vendored/requests/_internal_utils.py +50 -0
  184. snowflake/connector/vendored/requests/adapters.py +537 -0
  185. snowflake/connector/vendored/requests/api.py +157 -0
  186. snowflake/connector/vendored/requests/auth.py +315 -0
  187. snowflake/connector/vendored/requests/certs.py +17 -0
  188. snowflake/connector/vendored/requests/compat.py +79 -0
  189. snowflake/connector/vendored/requests/cookies.py +561 -0
  190. snowflake/connector/vendored/requests/exceptions.py +140 -0
  191. snowflake/connector/vendored/requests/help.py +134 -0
  192. snowflake/connector/vendored/requests/hooks.py +33 -0
  193. snowflake/connector/vendored/requests/models.py +1033 -0
  194. snowflake/connector/vendored/requests/sessions.py +833 -0
  195. snowflake/connector/vendored/requests/status_codes.py +128 -0
  196. snowflake/connector/vendored/requests/structures.py +99 -0
  197. snowflake/connector/vendored/requests/utils.py +1093 -0
  198. snowflake/connector/vendored/urllib3/LICENSE.txt +21 -0
  199. snowflake/connector/vendored/urllib3/__init__.py +85 -0
  200. snowflake/connector/vendored/urllib3/_collections.py +355 -0
  201. snowflake/connector/vendored/urllib3/_version.py +2 -0
  202. snowflake/connector/vendored/urllib3/connection.py +572 -0
  203. snowflake/connector/vendored/urllib3/connectionpool.py +1137 -0
  204. snowflake/connector/vendored/urllib3/contrib/__init__.py +0 -0
  205. snowflake/connector/vendored/urllib3/contrib/_appengine_environ.py +36 -0
  206. snowflake/connector/vendored/urllib3/contrib/_securetransport/__init__.py +0 -0
  207. snowflake/connector/vendored/urllib3/contrib/_securetransport/bindings.py +519 -0
  208. snowflake/connector/vendored/urllib3/contrib/_securetransport/low_level.py +397 -0
  209. snowflake/connector/vendored/urllib3/contrib/appengine.py +314 -0
  210. snowflake/connector/vendored/urllib3/contrib/ntlmpool.py +130 -0
  211. snowflake/connector/vendored/urllib3/contrib/pyopenssl.py +509 -0
  212. snowflake/connector/vendored/urllib3/contrib/securetransport.py +920 -0
  213. snowflake/connector/vendored/urllib3/contrib/socks.py +216 -0
  214. snowflake/connector/vendored/urllib3/exceptions.py +323 -0
  215. snowflake/connector/vendored/urllib3/fields.py +274 -0
  216. snowflake/connector/vendored/urllib3/filepost.py +98 -0
  217. snowflake/connector/vendored/urllib3/packages/__init__.py +0 -0
  218. snowflake/connector/vendored/urllib3/packages/backports/__init__.py +0 -0
  219. snowflake/connector/vendored/urllib3/packages/backports/makefile.py +51 -0
  220. snowflake/connector/vendored/urllib3/packages/backports/weakref_finalize.py +155 -0
  221. snowflake/connector/vendored/urllib3/packages/six.py +1076 -0
  222. snowflake/connector/vendored/urllib3/poolmanager.py +540 -0
  223. snowflake/connector/vendored/urllib3/request.py +191 -0
  224. snowflake/connector/vendored/urllib3/response.py +885 -0
  225. snowflake/connector/vendored/urllib3/util/__init__.py +49 -0
  226. snowflake/connector/vendored/urllib3/util/connection.py +156 -0
  227. snowflake/connector/vendored/urllib3/util/proxy.py +57 -0
  228. snowflake/connector/vendored/urllib3/util/queue.py +22 -0
  229. snowflake/connector/vendored/urllib3/util/request.py +146 -0
  230. snowflake/connector/vendored/urllib3/util/response.py +107 -0
  231. snowflake/connector/vendored/urllib3/util/retry.py +620 -0
  232. snowflake/connector/vendored/urllib3/util/ssl_.py +495 -0
  233. snowflake/connector/vendored/urllib3/util/ssl_match_hostname.py +159 -0
  234. snowflake/connector/vendored/urllib3/util/ssltransport.py +221 -0
  235. snowflake/connector/vendored/urllib3/util/timeout.py +271 -0
  236. snowflake/connector/vendored/urllib3/util/url.py +435 -0
  237. snowflake/connector/vendored/urllib3/util/wait.py +152 -0
  238. snowflake/connector/version.py +3 -0
  239. snowflake/connector/wif_util.py +407 -0
  240. snowflake_connector_python-3.16.0.dist-info/METADATA +1475 -0
  241. snowflake_connector_python-3.16.0.dist-info/RECORD +246 -0
  242. snowflake_connector_python-3.16.0.dist-info/WHEEL +5 -0
  243. snowflake_connector_python-3.16.0.dist-info/entry_points.txt +4 -0
  244. snowflake_connector_python-3.16.0.dist-info/licenses/LICENSE.txt +202 -0
  245. snowflake_connector_python-3.16.0.dist-info/licenses/NOTICE +8 -0
  246. snowflake_connector_python-3.16.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,397 @@
1
+ // Licensed to the Apache Software Foundation (ASF) under one
2
+ // or more contributor license agreements. See the NOTICE file
3
+ // distributed with this work for additional information
4
+ // regarding copyright ownership. The ASF licenses this file
5
+ // to you under the Apache License, Version 2.0 (the
6
+ // "License"); you may not use this file except in compliance
7
+ // with the License. You may obtain a copy of the License at
8
+ //
9
+ // http://www.apache.org/licenses/LICENSE-2.0
10
+ //
11
+ // Unless required by applicable law or agreed to in writing,
12
+ // software distributed under the License is distributed on an
13
+ // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ // KIND, either express or implied. See the License for the
15
+ // specific language governing permissions and limitations
16
+ // under the License.
17
+
18
+ #ifndef NANOARROW_IPC_H_INCLUDED
19
+ #define NANOARROW_IPC_H_INCLUDED
20
+
21
+ #include "nanoarrow.h"
22
+
23
+ #ifdef NANOARROW_NAMESPACE
24
+
25
+ #define ArrowIpcCheckRuntime \
26
+ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcCheckRuntime)
27
+ #define ArrowIpcSharedBufferIsThreadSafe \
28
+ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcSharedBufferIsThreadSafe)
29
+ #define ArrowIpcSharedBufferInit \
30
+ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcSharedBufferInit)
31
+ #define ArrowIpcSharedBufferReset \
32
+ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcSharedBufferReset)
33
+ #define ArrowIpcDecoderInit \
34
+ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcDecoderInit)
35
+ #define ArrowIpcDecoderReset \
36
+ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcDecoderReset)
37
+ #define ArrowIpcDecoderPeekHeader \
38
+ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcDecoderPeekHeader)
39
+ #define ArrowIpcDecoderVerifyHeader \
40
+ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcDecoderVerifyHeader)
41
+ #define ArrowIpcDecoderDecodeHeader \
42
+ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcDecoderDecodeHeader)
43
+ #define ArrowIpcDecoderDecodeSchema \
44
+ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcDecoderDecodeSchema)
45
+ #define ArrowIpcDecoderDecodeArrayView \
46
+ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcDecoderDecodeArrayView)
47
+ #define ArrowIpcDecoderDecodeArray \
48
+ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcDecoderDecodeArray)
49
+ #define ArrowIpcDecoderDecodeArrayFromShared \
50
+ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcDecoderDecodeArrayFromShared)
51
+ #define ArrowIpcDecoderSetSchema \
52
+ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcDecoderSetSchema)
53
+ #define ArrowIpcDecoderSetEndianness \
54
+ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcDecoderSetEndianness)
55
+ #define ArrowIpcInputStreamInitBuffer \
56
+ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcInputStreamInitBuffer)
57
+ #define ArrowIpcInputStreamInitFile \
58
+ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcInputStreamInitFile)
59
+ #define ArrowIpcInputStreamMove \
60
+ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcInputStreamMove)
61
+ #define ArrowIpcArrayStreamReaderInit \
62
+ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcArrayStreamReaderInit)
63
+
64
+ #endif
65
+
66
+ #ifdef __cplusplus
67
+ extern "C" {
68
+ #endif
69
+
70
+ /// \defgroup nanoarrow_ipc Nanoarrow IPC extension
71
+ ///
72
+ /// Except where noted, objects are not thread-safe and clients should
73
+ /// take care to serialize accesses to methods.
74
+ ///
75
+ /// Because this library is intended to be vendored, it provides full type
76
+ /// definitions and encourages clients to stack or statically allocate
77
+ /// where convenient.
78
+ ///
79
+ /// @{
80
+
81
+ /// \brief Metadata version enumerator
82
+ enum ArrowIpcMetadataVersion {
83
+ NANOARROW_IPC_METADATA_VERSION_V1,
84
+ NANOARROW_IPC_METADATA_VERSION_V2,
85
+ NANOARROW_IPC_METADATA_VERSION_V3,
86
+ NANOARROW_IPC_METADATA_VERSION_V4,
87
+ NANOARROW_IPC_METADATA_VERSION_V5
88
+ };
89
+
90
+ /// \brief Message type enumerator
91
+ enum ArrowIpcMessageType {
92
+ NANOARROW_IPC_MESSAGE_TYPE_UNINITIALIZED,
93
+ NANOARROW_IPC_MESSAGE_TYPE_SCHEMA,
94
+ NANOARROW_IPC_MESSAGE_TYPE_DICTIONARY_BATCH,
95
+ NANOARROW_IPC_MESSAGE_TYPE_RECORD_BATCH,
96
+ NANOARROW_IPC_MESSAGE_TYPE_TENSOR,
97
+ NANOARROW_IPC_MESSAGE_TYPE_SPARSE_TENSOR
98
+ };
99
+
100
+ /// \brief Endianness enumerator
101
+ enum ArrowIpcEndianness {
102
+ NANOARROW_IPC_ENDIANNESS_UNINITIALIZED,
103
+ NANOARROW_IPC_ENDIANNESS_LITTLE,
104
+ NANOARROW_IPC_ENDIANNESS_BIG
105
+ };
106
+
107
+ /// \brief Compression type enumerator
108
+ enum ArrowIpcCompressionType {
109
+ NANOARROW_IPC_COMPRESSION_TYPE_NONE,
110
+ NANOARROW_IPC_COMPRESSION_TYPE_LZ4_FRAME,
111
+ NANOARROW_IPC_COMPRESSION_TYPE_ZSTD
112
+ };
113
+
114
+ /// \brief Feature flag for a stream that uses dictionary replacement
115
+ #define NANOARROW_IPC_FEATURE_DICTIONARY_REPLACEMENT 1
116
+
117
+ /// \brief Feature flag for a stream that uses compression
118
+ #define NANOARROW_IPC_FEATURE_COMPRESSED_BODY 2
119
+
120
+ /// \brief Checks the nanoarrow runtime to make sure the run/build versions
121
+ /// match
122
+ ArrowErrorCode ArrowIpcCheckRuntime(struct ArrowError* error);
123
+
124
+ /// \brief A structure representing a reference-counted buffer that may be
125
+ /// passed to ArrowIpcDecoderDecodeArrayFromShared().
126
+ struct ArrowIpcSharedBuffer {
127
+ struct ArrowBuffer private_src;
128
+ };
129
+
130
+ /// \brief Initialize the contents of a ArrowIpcSharedBuffer struct
131
+ ///
132
+ /// If NANOARROW_OK is returned, the ArrowIpcSharedBuffer takes ownership of
133
+ /// src.
134
+ ArrowErrorCode ArrowIpcSharedBufferInit(struct ArrowIpcSharedBuffer* shared,
135
+ struct ArrowBuffer* src);
136
+
137
+ /// \brief Release the caller's copy of the shared buffer
138
+ ///
139
+ /// When finished, the caller must relinquish its own copy of the shared data
140
+ /// using this function. The original buffer will continue to exist until all
141
+ /// ArrowArray objects that refer to it have also been released.
142
+ void ArrowIpcSharedBufferReset(struct ArrowIpcSharedBuffer* shared);
143
+
144
+ /// \brief Check for shared buffer thread safety
145
+ ///
146
+ /// Thread-safe shared buffers require C11 and the stdatomic.h header.
147
+ /// If either are unavailable, shared buffers are still possible but
148
+ /// the resulting arrays must not be passed to other threads to be released.
149
+ int ArrowIpcSharedBufferIsThreadSafe(void);
150
+
151
+ /// \brief Decoder for Arrow IPC messages
152
+ ///
153
+ /// This structure is intended to be allocated by the caller,
154
+ /// initialized using ArrowIpcDecoderInit(), and released with
155
+ /// ArrowIpcDecoderReset(). These fields should not be modified
156
+ /// by the caller but can be read following a call to
157
+ /// ArrowIpcDecoderPeekHeader(), ArrowIpcDecoderVerifyHeader(), or
158
+ /// ArrowIpcDecoderDecodeHeader().
159
+ struct ArrowIpcDecoder {
160
+ /// \brief The last verified or decoded message type
161
+ enum ArrowIpcMessageType message_type;
162
+
163
+ /// \brief The metadata version as indicated by the current schema message
164
+ enum ArrowIpcMetadataVersion metadata_version;
165
+
166
+ /// \brief Buffer endianness as indicated by the current schema message
167
+ enum ArrowIpcEndianness endianness;
168
+
169
+ /// \brief Arrow IPC Features used as indicated by the current Schema message
170
+ int32_t feature_flags;
171
+
172
+ /// \brief Compression used by the current RecordBatch message
173
+ enum ArrowIpcCompressionType codec;
174
+
175
+ /// \brief The number of bytes in the current header message
176
+ ///
177
+ /// This value includes the 8 bytes before the start of the header message
178
+ /// content and any padding bytes required to make the header message size
179
+ /// be a multiple of 8 bytes.
180
+ int32_t header_size_bytes;
181
+
182
+ /// \brief The number of bytes in the forthcoming body message.
183
+ int64_t body_size_bytes;
184
+
185
+ /// \brief Private resources managed by this library
186
+ void* private_data;
187
+ };
188
+
189
+ /// \brief Initialize a decoder
190
+ ArrowErrorCode ArrowIpcDecoderInit(struct ArrowIpcDecoder* decoder);
191
+
192
+ /// \brief Release all resources attached to a decoder
193
+ void ArrowIpcDecoderReset(struct ArrowIpcDecoder* decoder);
194
+
195
+ /// \brief Peek at a message header
196
+ ///
197
+ /// The first 8 bytes of an Arrow IPC message are 0xFFFFFF followed by the size
198
+ /// of the header as a little-endian 32-bit integer. ArrowIpcDecoderPeekHeader()
199
+ /// reads these bytes and returns ESPIPE if there are not enough remaining bytes
200
+ /// in data to read the entire header message, EINVAL if the first 8 bytes are
201
+ /// not valid, ENODATA if the Arrow end-of-stream indicator has been reached, or
202
+ /// NANOARROW_OK otherwise.
203
+ ArrowErrorCode ArrowIpcDecoderPeekHeader(struct ArrowIpcDecoder* decoder,
204
+ struct ArrowBufferView data,
205
+ struct ArrowError* error);
206
+
207
+ /// \brief Verify a message header
208
+ ///
209
+ /// Runs ArrowIpcDecoderPeekHeader() to ensure data is sufficiently large but
210
+ /// additionally runs flatbuffer verification to ensure that decoding the data
211
+ /// will not access memory outside of the buffer specified by data.
212
+ /// ArrowIpcDecoderVerifyHeader() will also set decoder.header_size_bytes,
213
+ /// decoder.body_size_bytes, decoder.metadata_version, and decoder.message_type.
214
+ ///
215
+ /// Returns as ArrowIpcDecoderPeekHeader() and additionally will
216
+ /// return EINVAL if flatbuffer verification fails.
217
+ ArrowErrorCode ArrowIpcDecoderVerifyHeader(struct ArrowIpcDecoder* decoder,
218
+ struct ArrowBufferView data,
219
+ struct ArrowError* error);
220
+
221
+ /// \brief Decode a message header
222
+ ///
223
+ /// Runs ArrowIpcDecoderPeekHeader() to ensure data is sufficiently large and
224
+ /// decodes the content of the message header. If data contains a schema
225
+ /// message, decoder.endianness and decoder.feature_flags is set and
226
+ /// ArrowIpcDecoderDecodeSchema() can be used to obtain the decoded schema. If
227
+ /// data contains a record batch message, decoder.codec is set and a successful
228
+ /// call can be followed by a call to ArrowIpcDecoderDecodeArray().
229
+ ///
230
+ /// In almost all cases this should be preceded by a call to
231
+ /// ArrowIpcDecoderVerifyHeader() to ensure decoding does not access data
232
+ /// outside of the specified buffer.
233
+ ///
234
+ /// Returns EINVAL if the content of the message cannot be decoded or ENOTSUP if
235
+ /// the content of the message uses features not supported by this library.
236
+ ArrowErrorCode ArrowIpcDecoderDecodeHeader(struct ArrowIpcDecoder* decoder,
237
+ struct ArrowBufferView data,
238
+ struct ArrowError* error);
239
+
240
+ /// \brief Decode an ArrowSchema
241
+ ///
242
+ /// After a successful call to ArrowIpcDecoderDecodeHeader(), retrieve an
243
+ /// ArrowSchema. The caller is responsible for releasing the schema if
244
+ /// NANOARROW_OK is returned.
245
+ ///
246
+ /// Returns EINVAL if the decoder did not just decode a schema message or
247
+ /// NANOARROW_OK otherwise.
248
+ ArrowErrorCode ArrowIpcDecoderDecodeSchema(struct ArrowIpcDecoder* decoder,
249
+ struct ArrowSchema* out,
250
+ struct ArrowError* error);
251
+
252
+ /// \brief Set the ArrowSchema used to decode future record batch messages
253
+ ///
254
+ /// Prepares the decoder for future record batch messages
255
+ /// of this type. The decoder takes ownership of schema if NANOARROW_OK is
256
+ /// returned. Note that you must call this explicitly after decoding a Schema
257
+ /// message (i.e., the decoder does not assume that the last-decoded schema
258
+ /// message applies to future record batch messages).
259
+ ///
260
+ /// Returns EINVAL if schema validation fails or NANOARROW_OK otherwise.
261
+ ArrowErrorCode ArrowIpcDecoderSetSchema(struct ArrowIpcDecoder* decoder,
262
+ struct ArrowSchema* schema,
263
+ struct ArrowError* error);
264
+
265
+ /// \brief Set the endianness used to decode future record batch messages
266
+ ///
267
+ /// Prepares the decoder for future record batch messages with the specified
268
+ /// endianness. Note that you must call this explicitly after decoding a
269
+ /// Schema message (i.e., the decoder does not assume that the last-decoded
270
+ /// schema message applies to future record batch messages).
271
+ ///
272
+ /// Returns NANOARROW_OK on success.
273
+ ArrowErrorCode ArrowIpcDecoderSetEndianness(struct ArrowIpcDecoder* decoder,
274
+ enum ArrowIpcEndianness endianness);
275
+
276
+ /// \brief Decode an ArrowArrayView
277
+ ///
278
+ /// After a successful call to ArrowIpcDecoderDecodeHeader(), deserialize the
279
+ /// content of body into an internally-managed ArrowArrayView and return it.
280
+ /// Note that field index does not equate to column index if any columns contain
281
+ /// nested types. Use a value of -1 to decode the entire array into a struct.
282
+ /// The pointed-to ArrowArrayView is owned by the ArrowIpcDecoder and must not
283
+ /// be released.
284
+ ///
285
+ /// For streams that match system endianness and do not use compression, this
286
+ /// operation will not perform any heap allocations; however, the buffers
287
+ /// referred to by the returned ArrowArrayView are only valid as long as the
288
+ /// buffer referred to by body stays valid.
289
+ ArrowErrorCode ArrowIpcDecoderDecodeArrayView(struct ArrowIpcDecoder* decoder,
290
+ struct ArrowBufferView body,
291
+ int64_t i,
292
+ struct ArrowArrayView** out,
293
+ struct ArrowError* error);
294
+
295
+ /// \brief Decode an ArrowArray
296
+ ///
297
+ /// After a successful call to ArrowIpcDecoderDecodeHeader(), assemble an
298
+ /// ArrowArray given a message body and a field index. Note that field index
299
+ /// does not equate to column index if any columns contain nested types. Use a
300
+ /// value of -1 to decode the entire array into a struct. The caller is
301
+ /// responsible for releasing the array if NANOARROW_OK is returned.
302
+ ///
303
+ /// Returns EINVAL if the decoder did not just decode a record batch message,
304
+ /// ENOTSUP if the message uses features not supported by this library, or or
305
+ /// NANOARROW_OK otherwise.
306
+ ArrowErrorCode ArrowIpcDecoderDecodeArray(
307
+ struct ArrowIpcDecoder* decoder, struct ArrowBufferView body, int64_t i,
308
+ struct ArrowArray* out, enum ArrowValidationLevel validation_level,
309
+ struct ArrowError* error);
310
+
311
+ /// \brief Decode an ArrowArray from an owned buffer
312
+ ///
313
+ /// This implementation takes advantage of the fact that it can avoid copying
314
+ /// individual buffers. In all cases the caller must ArrowIpcSharedBufferReset()
315
+ /// body after one or more calls to ArrowIpcDecoderDecodeArrayFromShared(). If
316
+ /// ArrowIpcSharedBufferIsThreadSafe() returns 0, out must not be released by
317
+ /// another thread.
318
+ ArrowErrorCode ArrowIpcDecoderDecodeArrayFromShared(
319
+ struct ArrowIpcDecoder* decoder, struct ArrowIpcSharedBuffer* shared,
320
+ int64_t i, struct ArrowArray* out,
321
+ enum ArrowValidationLevel validation_level, struct ArrowError* error);
322
+
323
+ /// \brief An user-extensible input data source
324
+ struct ArrowIpcInputStream {
325
+ /// \brief Read up to buf_size_bytes from stream into buf
326
+ ///
327
+ /// The actual number of bytes read is placed in the value pointed to by
328
+ /// size_read_out. Returns NANOARROW_OK on success.
329
+ ArrowErrorCode (*read)(struct ArrowIpcInputStream* stream, uint8_t* buf,
330
+ int64_t buf_size_bytes, int64_t* size_read_out,
331
+ struct ArrowError* error);
332
+
333
+ /// \brief Release the stream and any resources it may be holding
334
+ ///
335
+ /// Release callback implementations must set the release member to NULL.
336
+ /// Callers must check that the release callback is not NULL before calling
337
+ /// read() or release().
338
+ void (*release)(struct ArrowIpcInputStream* stream);
339
+
340
+ /// \brief Private implementation-defined data
341
+ void* private_data;
342
+ };
343
+
344
+ /// \brief Transfer ownership of an ArrowIpcInputStream
345
+ void ArrowIpcInputStreamMove(struct ArrowIpcInputStream* src,
346
+ struct ArrowIpcInputStream* dst);
347
+
348
+ /// \brief Create an input stream from an ArrowBuffer
349
+ ArrowErrorCode ArrowIpcInputStreamInitBuffer(struct ArrowIpcInputStream* stream,
350
+ struct ArrowBuffer* input);
351
+
352
+ /// \brief Create an input stream from a C FILE* pointer
353
+ ///
354
+ /// Note that the ArrowIpcInputStream has no mechanism to communicate an error
355
+ /// if file_ptr fails to close. If this behaviour is needed, pass false to
356
+ /// close_on_release and handle closing the file independently from stream.
357
+ ArrowErrorCode ArrowIpcInputStreamInitFile(struct ArrowIpcInputStream* stream,
358
+ void* file_ptr,
359
+ int close_on_release);
360
+
361
+ /// \brief Options for ArrowIpcArrayStreamReaderInit()
362
+ struct ArrowIpcArrayStreamReaderOptions {
363
+ /// \brief The field index to extract.
364
+ ///
365
+ /// Defaults to -1 (i.e., read all fields). Note that this field index refers
366
+ /// to the flattened tree of children and not necessarily the column index.
367
+ int64_t field_index;
368
+
369
+ /// \brief Set to a non-zero value to share the message body buffer among
370
+ /// decoded arrays
371
+ ///
372
+ /// Sharing buffers is a good choice when (1) using memory-mapped IO
373
+ /// (since unreferenced portions of the file are often not loaded into memory)
374
+ /// or (2) if all data from all columns are about to be referenced anyway.
375
+ /// When loading a single field there is probably no advantage to using shared
376
+ /// buffers. Defaults to the value of ArrowIpcSharedBufferIsThreadSafe().
377
+ int use_shared_buffers;
378
+ };
379
+
380
+ /// \brief Initialize an ArrowArrayStream from an input stream of bytes
381
+ ///
382
+ /// The stream of bytes must begin with a Schema message and be followed by
383
+ /// zero or more RecordBatch messages as described in the Arrow IPC stream
384
+ /// format specification. Returns NANOARROW_OK on success. If NANOARROW_OK
385
+ /// is returned, the ArrowArrayStream takes ownership of input_stream and
386
+ /// the caller is responsible for releasing out.
387
+ ArrowErrorCode ArrowIpcArrayStreamReaderInit(
388
+ struct ArrowArrayStream* out, struct ArrowIpcInputStream* input_stream,
389
+ struct ArrowIpcArrayStreamReaderOptions* options);
390
+
391
+ /// @}
392
+
393
+ #ifdef __cplusplus
394
+ }
395
+ #endif
396
+
397
+ #endif
@@ -0,0 +1,100 @@
1
+ #include "logging.hpp"
2
+
3
+ #include <cstdio>
4
+
5
+ #include "Python/Helpers.hpp"
6
+
7
+ namespace sf {
8
+ std::string Logger::formatString(const char *format, ...) {
9
+ char msg[1000] = {0};
10
+ va_list args;
11
+ va_start(args, format);
12
+ vsnprintf(msg, sizeof(msg), format, args);
13
+ va_end(args);
14
+
15
+ return std::string(msg);
16
+ }
17
+
18
+ void Logger::setupPyLogger() {
19
+ py::UniqueRef pyLoggingModule;
20
+ py::importPythonModule("snowflake.connector.snow_logging", pyLoggingModule);
21
+ PyObject *logger =
22
+ PyObject_CallMethod(pyLoggingModule.get(), "getSnowLogger", "s", m_name);
23
+
24
+ m_pyLogger.reset(logger);
25
+ }
26
+
27
+ Logger::Logger(const char *name) : m_name(name) {}
28
+
29
+ void Logger::log(int level, const char *path_name, const char *func_name,
30
+ int line_num, const char *msg) {
31
+ if (m_pyLogger.get() == nullptr) {
32
+ setupPyLogger();
33
+ }
34
+
35
+ PyObject *logger = m_pyLogger.get();
36
+ py::UniqueRef keywords(PyDict_New());
37
+ py::UniqueRef call_log(PyObject_GetAttrString(logger, "log"));
38
+
39
+ // prepare keyword args for snow_logger
40
+ py::UniqueRef level_ref(Py_BuildValue("i", level));
41
+ py::UniqueRef path_name_ref(Py_BuildValue("s", path_name));
42
+ py::UniqueRef func_name_ref(Py_BuildValue("s", func_name));
43
+ py::UniqueRef line_num_ref(Py_BuildValue("i", line_num));
44
+ py::UniqueRef msg_ref(Py_BuildValue("s", msg));
45
+
46
+ PyDict_SetItemString(keywords.get(), "level", level_ref.get());
47
+ PyDict_SetItemString(keywords.get(), "path_name", path_name_ref.get());
48
+ PyDict_SetItemString(keywords.get(), "func_name", func_name_ref.get());
49
+ PyDict_SetItemString(keywords.get(), "line_num", line_num_ref.get());
50
+ PyDict_SetItemString(keywords.get(), "msg", msg_ref.get());
51
+
52
+ // call snow_logging.SnowLogger.log()
53
+ PyObject_Call(call_log.get(), Py_BuildValue("()"), keywords.get());
54
+ }
55
+
56
+ void Logger::debug(const char *path_name, const char *func_name, int line_num,
57
+ const char *format, ...) {
58
+ char msg[1000] = {0};
59
+ va_list args;
60
+ va_start(args, format);
61
+ vsnprintf(msg, sizeof(msg), format, args);
62
+ va_end(args);
63
+
64
+ Logger::log(DEBUG, path_name, func_name, line_num, msg);
65
+ }
66
+
67
+ void Logger::info(const char *path_name, const char *func_name, int line_num,
68
+ const char *format, ...) {
69
+ char msg[1000] = {0};
70
+ va_list args;
71
+ va_start(args, format);
72
+ vsnprintf(msg, sizeof(msg), format, args);
73
+ va_end(args);
74
+
75
+ Logger::log(INFO, path_name, func_name, line_num, msg);
76
+ }
77
+
78
+ void Logger::warn(const char *path_name, const char *func_name, int line_num,
79
+ const char *format, ...) {
80
+ char msg[1000] = {0};
81
+ va_list args;
82
+ va_start(args, format);
83
+ vsnprintf(msg, sizeof(msg), format, args);
84
+ va_end(args);
85
+
86
+ Logger::log(WARN, path_name, func_name, line_num, msg);
87
+ }
88
+
89
+ void Logger::error(const char *path_name, const char *func_name, int line_num,
90
+ const char *format, ...) {
91
+ char msg[1000] = {0};
92
+ va_list args;
93
+ va_start(args, format);
94
+ vsnprintf(msg, sizeof(msg), format, args);
95
+ va_end(args);
96
+
97
+ Logger::log(ERROR, path_name, func_name, line_num, msg);
98
+ }
99
+
100
+ } // namespace sf
@@ -0,0 +1,49 @@
1
+ #ifndef PC_LOGGING_HPP
2
+ #define PC_LOGGING_HPP
3
+
4
+ #include <string>
5
+
6
+ #include "Python/Common.hpp"
7
+
8
+ namespace sf {
9
+
10
+ class Logger {
11
+ public:
12
+ explicit Logger(const char *name);
13
+
14
+ void log(int level, const char *path_name, const char *func_name,
15
+ int line_num, const char *msg);
16
+
17
+ void debug(const char *path_name, const char *func_name, int line_num,
18
+ const char *format, ...);
19
+
20
+ void info(const char *path_name, const char *func_name, int line_num,
21
+ const char *format, ...);
22
+
23
+ void warn(const char *path_name, const char *func_name, int line_num,
24
+ const char *format, ...);
25
+
26
+ void error(const char *path_name, const char *func_name, int line_num,
27
+ const char *format, ...);
28
+
29
+ static std::string formatString(const char *fmt, ...);
30
+
31
+ private:
32
+ py::UniqueRef m_pyLogger;
33
+ const char *const m_name;
34
+ static constexpr int CRITICAL = 50;
35
+ static constexpr int FATAL = CRITICAL;
36
+ static constexpr int ERROR = 40;
37
+ static constexpr int WARNING = 30;
38
+ static constexpr int WARN = WARNING;
39
+ static constexpr int INFO = 20;
40
+ static constexpr int DEBUG = 10;
41
+ static constexpr int NOTSET = 0;
42
+ static constexpr int LINE_NUM = 0;
43
+
44
+ void setupPyLogger();
45
+ };
46
+
47
+ } // namespace sf
48
+
49
+ #endif // PC_LOGGING_HPP