snowflake-connector-python 5.2.0__cp315-cp315-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 (204) hide show
  1. snowflake/connector/__init__.py +148 -0
  2. snowflake/connector/_common/__init__.py +0 -0
  3. snowflake/connector/_common/extras.py +134 -0
  4. snowflake/connector/_common/telemetry.py +221 -0
  5. snowflake/connector/_common/wif_util.py +92 -0
  6. snowflake/connector/_core/sf_core_python.cp315-win_amd64.pyd +0 -0
  7. snowflake/connector/_core/sf_core_python.pyi +79 -0
  8. snowflake/connector/_internal/__init__.py +6 -0
  9. snowflake/connector/_internal/_private_key_helper.py +31 -0
  10. snowflake/connector/_internal/api_client/__init__.py +93 -0
  11. snowflake/connector/_internal/api_client/bridge.py +41 -0
  12. snowflake/connector/_internal/api_client/client_api.py +976 -0
  13. snowflake/connector/_internal/arrow.py +47 -0
  14. snowflake/connector/_internal/arrow_context.py +240 -0
  15. snowflake/connector/_internal/arrow_stream_async.py +266 -0
  16. snowflake/connector/_internal/arrow_stream_iterator.cp311-win_amd64.pyd +0 -0
  17. snowflake/connector/_internal/arrow_stream_iterator.cp312-win_amd64.pyd +0 -0
  18. snowflake/connector/_internal/arrow_stream_iterator.cp313-win_amd64.pyd +0 -0
  19. snowflake/connector/_internal/arrow_stream_iterator.cp314-win_amd64.pyd +0 -0
  20. snowflake/connector/_internal/arrow_stream_iterator.cp314t-win_amd64.pyd +0 -0
  21. snowflake/connector/_internal/arrow_stream_iterator.cp315-win_amd64.pyd +0 -0
  22. snowflake/connector/_internal/arrow_stream_iterator.pyi +42 -0
  23. snowflake/connector/_internal/arrow_stream_utils.py +171 -0
  24. snowflake/connector/_internal/authenticator_type.py +53 -0
  25. snowflake/connector/_internal/backward_compatibility.py +245 -0
  26. snowflake/connector/_internal/binding_converters.py +741 -0
  27. snowflake/connector/_internal/config_utils.py +71 -0
  28. snowflake/connector/_internal/connection/__init__.py +39 -0
  29. snowflake/connector/_internal/connection/connection.py +616 -0
  30. snowflake/connector/_internal/connection/connection_types.py +13 -0
  31. snowflake/connector/_internal/connection/constants.py +25 -0
  32. snowflake/connector/_internal/connection/decorators.py +31 -0
  33. snowflake/connector/_internal/connection/freezable_proxy.py +104 -0
  34. snowflake/connector/_internal/connection/queries.py +10 -0
  35. snowflake/connector/_internal/connection_config_mixin.py +755 -0
  36. snowflake/connector/_internal/cursor/__init__.py +25 -0
  37. snowflake/connector/_internal/cursor/base.py +732 -0
  38. snowflake/connector/_internal/cursor/cursor_types.py +13 -0
  39. snowflake/connector/_internal/cursor/decorators.py +56 -0
  40. snowflake/connector/_internal/cursor/query_result.py +202 -0
  41. snowflake/connector/_internal/cursor/query_result_waiter.py +98 -0
  42. snowflake/connector/_internal/cursor/result_metadata.py +255 -0
  43. snowflake/connector/_internal/cursor/result_set_wrapper.py +66 -0
  44. snowflake/connector/_internal/decorators.py +539 -0
  45. snowflake/connector/_internal/error_kinds.py +111 -0
  46. snowflake/connector/_internal/errorcode.py +35 -0
  47. snowflake/connector/_internal/errorhandler.py +278 -0
  48. snowflake/connector/_internal/fips.py +28 -0
  49. snowflake/connector/_internal/logging/__init__.py +52 -0
  50. snowflake/connector/_internal/logging/config.py +134 -0
  51. snowflake/connector/_internal/logging/core_logger.py +218 -0
  52. snowflake/connector/_internal/logging/native_extension_logger.py +144 -0
  53. snowflake/connector/_internal/logout_config_mapping.py +187 -0
  54. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/ArrayConverter.cpp +57 -0
  55. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/ArrayConverter.hpp +29 -0
  56. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/ArrowTableConverter.cpp +943 -0
  57. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/ArrowTableConverter.hpp +63 -0
  58. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/BinaryConverter.cpp +18 -0
  59. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/BinaryConverter.hpp +26 -0
  60. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/BooleanConverter.cpp +21 -0
  61. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/BooleanConverter.hpp +23 -0
  62. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/CArrowIterator.cpp +118 -0
  63. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/CArrowIterator.hpp +116 -0
  64. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/CArrowStreamIterator.cpp +323 -0
  65. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/CArrowStreamIterator.hpp +133 -0
  66. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/CArrowStreamTableIterator.cpp +275 -0
  67. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/CArrowStreamTableIterator.hpp +168 -0
  68. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/ConverterUtil.cpp +439 -0
  69. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/ConverterUtil.hpp +30 -0
  70. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/DateConverter.cpp +48 -0
  71. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/DateConverter.hpp +46 -0
  72. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/DecFloatConverter.cpp +76 -0
  73. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/DecFloatConverter.hpp +35 -0
  74. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/DecimalConverter.cpp +90 -0
  75. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/DecimalConverter.hpp +63 -0
  76. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/FixedSizeListConverter.cpp +62 -0
  77. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/FixedSizeListConverter.hpp +28 -0
  78. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/FloatConverter.cpp +29 -0
  79. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/FloatConverter.hpp +35 -0
  80. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/IColumnConverter.hpp +17 -0
  81. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/IntConverter.cpp +23 -0
  82. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/IntConverter.hpp +41 -0
  83. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/IntervalConverter.cpp +65 -0
  84. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/IntervalConverter.hpp +54 -0
  85. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/LICENSE.txt +209 -0
  86. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/MapConverter.cpp +79 -0
  87. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/MapConverter.hpp +30 -0
  88. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/ObjectConverter.cpp +52 -0
  89. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/ObjectConverter.hpp +29 -0
  90. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/Python/Common.cpp +8 -0
  91. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/Python/Common.hpp +117 -0
  92. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/Python/Helpers.cpp +54 -0
  93. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/Python/Helpers.hpp +34 -0
  94. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/SnowflakeType.cpp +33 -0
  95. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/SnowflakeType.hpp +48 -0
  96. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/StringConverter.cpp +18 -0
  97. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/StringConverter.hpp +26 -0
  98. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/TimeConverter.cpp +39 -0
  99. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/TimeConverter.hpp +31 -0
  100. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/TimeStampConverter.cpp +326 -0
  101. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/TimeStampConverter.hpp +138 -0
  102. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/Util/macros.hpp +14 -0
  103. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/Util/time.cpp +65 -0
  104. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/Util/time.hpp +68 -0
  105. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/arrow_stream_iterator.cpp +13278 -0
  106. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/arrow_stream_iterator.pyx +204 -0
  107. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_accessors.h +109 -0
  108. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_alloc.h +125 -0
  109. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_assert.h +45 -0
  110. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_builder.h +1914 -0
  111. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_emitter.h +208 -0
  112. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_endian.h +128 -0
  113. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_epilogue.h +7 -0
  114. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_flatbuffers.h +58 -0
  115. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_identifier.h +144 -0
  116. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_iov.h +31 -0
  117. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_prologue.h +8 -0
  118. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_refmap.h +144 -0
  119. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_rtconfig.h +160 -0
  120. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_types.h +98 -0
  121. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_verifier.h +243 -0
  122. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/portable/flatcc_portable.h +14 -0
  123. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/portable/paligned_alloc.h +207 -0
  124. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/portable/pattributes.h +80 -0
  125. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/portable/pdiagnostic.h +83 -0
  126. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/portable/pdiagnostic_pop.h +20 -0
  127. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/portable/pdiagnostic_push.h +51 -0
  128. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/portable/pendian.h +201 -0
  129. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/portable/pendian_detect.h +108 -0
  130. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/portable/pinline.h +19 -0
  131. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/portable/pinttypes.h +52 -0
  132. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/portable/portable.h +2 -0
  133. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/portable/portable_basic.h +25 -0
  134. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/portable/pstatic_assert.h +67 -0
  135. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/portable/pstdalign.h +164 -0
  136. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/portable/pstdint.h +926 -0
  137. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/portable/punaligned.h +182 -0
  138. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/portable/pversion.h +6 -0
  139. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/portable/pwarnings.h +52 -0
  140. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc.c +3052 -0
  141. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/nanoarrow.c +3019 -0
  142. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/nanoarrow.h +3354 -0
  143. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/nanoarrow.hpp +344 -0
  144. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/nanoarrow_ipc.c +29305 -0
  145. snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/nanoarrow_ipc.h +381 -0
  146. snowflake/connector/_internal/nanoarrow_cpp/Logging/logging.cpp +108 -0
  147. snowflake/connector/_internal/nanoarrow_cpp/Logging/logging.hpp +47 -0
  148. snowflake/connector/_internal/nanoarrow_cpp/scripts/.clang-format +8 -0
  149. snowflake/connector/_internal/nanoarrow_cpp/scripts/format.sh +8 -0
  150. snowflake/connector/_internal/protobuf_gen/__init__.py +0 -0
  151. snowflake/connector/_internal/protobuf_gen/database_driver_v1_pb2.py +408 -0
  152. snowflake/connector/_internal/protobuf_gen/database_driver_v1_pb2.pyi +4487 -0
  153. snowflake/connector/_internal/protobuf_gen/database_driver_v1_services.py +2088 -0
  154. snowflake/connector/_internal/protobuf_gen/proto_exception.py +17 -0
  155. snowflake/connector/_internal/result_batch.py +150 -0
  156. snowflake/connector/_internal/snowflake_restful.py +222 -0
  157. snowflake/connector/_internal/snowpark_backcompat_helpers.py +31 -0
  158. snowflake/connector/_internal/sqlstate.py +11 -0
  159. snowflake/connector/_internal/statement_utils.py +207 -0
  160. snowflake/connector/_internal/text_utils.py +112 -0
  161. snowflake/connector/_internal/type_codes.py +139 -0
  162. snowflake/connector/_internal/utils.py +65 -0
  163. snowflake/connector/_internal/write_pandas_operation.py +657 -0
  164. snowflake/connector/aio/README.md +168 -0
  165. snowflake/connector/aio/__init__.py +37 -0
  166. snowflake/connector/aio/connection/__init__.py +17 -0
  167. snowflake/connector/aio/connection/_connection.py +506 -0
  168. snowflake/connector/aio/cursor/__init__.py +35 -0
  169. snowflake/connector/aio/cursor/_base.py +1034 -0
  170. snowflake/connector/aio/cursor/_dict_cursor.py +78 -0
  171. snowflake/connector/aio/cursor/_result_set_wrapper.py +35 -0
  172. snowflake/connector/aio/cursor/_snowflake_cursor.py +72 -0
  173. snowflake/connector/aio/pandas_tools.py +279 -0
  174. snowflake/connector/aio/result_batch.py +165 -0
  175. snowflake/connector/auth/__init__.py +0 -0
  176. snowflake/connector/auth/workload_identity.py +5 -0
  177. snowflake/connector/compat.py +22 -0
  178. snowflake/connector/config_manager.py +392 -0
  179. snowflake/connector/connection/__init__.py +30 -0
  180. snowflake/connector/connection/_connection.py +641 -0
  181. snowflake/connector/connection_config.py +517 -0
  182. snowflake/connector/constants.py +52 -0
  183. snowflake/connector/cursor/__init__.py +37 -0
  184. snowflake/connector/cursor/_base.py +1169 -0
  185. snowflake/connector/cursor/_chunked_download_reader.py +75 -0
  186. snowflake/connector/cursor/_dict_cursor.py +78 -0
  187. snowflake/connector/cursor/_result_set_wrapper.py +35 -0
  188. snowflake/connector/cursor/_snowflake_cursor.py +72 -0
  189. snowflake/connector/description.py +7 -0
  190. snowflake/connector/errors.py +492 -0
  191. snowflake/connector/network.py +71 -0
  192. snowflake/connector/pandas_tools.py +191 -0
  193. snowflake/connector/py.typed +0 -0
  194. snowflake/connector/result_batch.py +216 -0
  195. snowflake/connector/telemetry.py +40 -0
  196. snowflake/connector/time_util.py +11 -0
  197. snowflake/connector/types.py +134 -0
  198. snowflake/connector/util_text.py +3 -0
  199. snowflake/connector/version.py +23 -0
  200. snowflake_connector_python-5.2.0.dist-info/DELVEWHEEL +2 -0
  201. snowflake_connector_python-5.2.0.dist-info/METADATA +190 -0
  202. snowflake_connector_python-5.2.0.dist-info/RECORD +204 -0
  203. snowflake_connector_python-5.2.0.dist-info/WHEEL +4 -0
  204. snowflake_connector_python.libs/msvcp140-a4c2229bdc2a2a630acdc095b4d86008.dll +0 -0
@@ -0,0 +1,381 @@
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 NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcCheckRuntime)
26
+ #define ArrowIpcSharedBufferIsThreadSafe \
27
+ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcSharedBufferIsThreadSafe)
28
+ #define ArrowIpcSharedBufferInit NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcSharedBufferInit)
29
+ #define ArrowIpcSharedBufferReset NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcSharedBufferReset)
30
+ #define ArrowIpcDecoderInit NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcDecoderInit)
31
+ #define ArrowIpcDecoderReset NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcDecoderReset)
32
+ #define ArrowIpcDecoderPeekHeader NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcDecoderPeekHeader)
33
+ #define ArrowIpcDecoderVerifyHeader \
34
+ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcDecoderVerifyHeader)
35
+ #define ArrowIpcDecoderDecodeHeader \
36
+ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcDecoderDecodeHeader)
37
+ #define ArrowIpcDecoderDecodeSchema \
38
+ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcDecoderDecodeSchema)
39
+ #define ArrowIpcDecoderDecodeArrayView \
40
+ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcDecoderDecodeArrayView)
41
+ #define ArrowIpcDecoderDecodeArray NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcDecoderDecodeArray)
42
+ #define ArrowIpcDecoderDecodeArrayFromShared \
43
+ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcDecoderDecodeArrayFromShared)
44
+ #define ArrowIpcDecoderSetSchema NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcDecoderSetSchema)
45
+ #define ArrowIpcDecoderSetEndianness \
46
+ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcDecoderSetEndianness)
47
+ #define ArrowIpcInputStreamInitBuffer \
48
+ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcInputStreamInitBuffer)
49
+ #define ArrowIpcInputStreamInitFile \
50
+ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcInputStreamInitFile)
51
+ #define ArrowIpcInputStreamMove NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcInputStreamMove)
52
+ #define ArrowIpcArrayStreamReaderInit \
53
+ NANOARROW_SYMBOL(NANOARROW_NAMESPACE, ArrowIpcArrayStreamReaderInit)
54
+
55
+ #endif
56
+
57
+ #ifdef __cplusplus
58
+ extern "C" {
59
+ #endif
60
+
61
+ /// \defgroup nanoarrow_ipc Nanoarrow IPC extension
62
+ ///
63
+ /// Except where noted, objects are not thread-safe and clients should
64
+ /// take care to serialize accesses to methods.
65
+ ///
66
+ /// Because this library is intended to be vendored, it provides full type
67
+ /// definitions and encourages clients to stack or statically allocate
68
+ /// where convenient.
69
+ ///
70
+ /// @{
71
+
72
+ /// \brief Metadata version enumerator
73
+ enum ArrowIpcMetadataVersion {
74
+ NANOARROW_IPC_METADATA_VERSION_V1,
75
+ NANOARROW_IPC_METADATA_VERSION_V2,
76
+ NANOARROW_IPC_METADATA_VERSION_V3,
77
+ NANOARROW_IPC_METADATA_VERSION_V4,
78
+ NANOARROW_IPC_METADATA_VERSION_V5
79
+ };
80
+
81
+ /// \brief Message type enumerator
82
+ enum ArrowIpcMessageType {
83
+ NANOARROW_IPC_MESSAGE_TYPE_UNINITIALIZED,
84
+ NANOARROW_IPC_MESSAGE_TYPE_SCHEMA,
85
+ NANOARROW_IPC_MESSAGE_TYPE_DICTIONARY_BATCH,
86
+ NANOARROW_IPC_MESSAGE_TYPE_RECORD_BATCH,
87
+ NANOARROW_IPC_MESSAGE_TYPE_TENSOR,
88
+ NANOARROW_IPC_MESSAGE_TYPE_SPARSE_TENSOR
89
+ };
90
+
91
+ /// \brief Endianness enumerator
92
+ enum ArrowIpcEndianness {
93
+ NANOARROW_IPC_ENDIANNESS_UNINITIALIZED,
94
+ NANOARROW_IPC_ENDIANNESS_LITTLE,
95
+ NANOARROW_IPC_ENDIANNESS_BIG
96
+ };
97
+
98
+ /// \brief Compression type enumerator
99
+ enum ArrowIpcCompressionType {
100
+ NANOARROW_IPC_COMPRESSION_TYPE_NONE,
101
+ NANOARROW_IPC_COMPRESSION_TYPE_LZ4_FRAME,
102
+ NANOARROW_IPC_COMPRESSION_TYPE_ZSTD
103
+ };
104
+
105
+ /// \brief Feature flag for a stream that uses dictionary replacement
106
+ #define NANOARROW_IPC_FEATURE_DICTIONARY_REPLACEMENT 1
107
+
108
+ /// \brief Feature flag for a stream that uses compression
109
+ #define NANOARROW_IPC_FEATURE_COMPRESSED_BODY 2
110
+
111
+ /// \brief Checks the nanoarrow runtime to make sure the run/build versions
112
+ /// match
113
+ ArrowErrorCode ArrowIpcCheckRuntime(struct ArrowError* error);
114
+
115
+ /// \brief A structure representing a reference-counted buffer that may be
116
+ /// passed to ArrowIpcDecoderDecodeArrayFromShared().
117
+ struct ArrowIpcSharedBuffer {
118
+ struct ArrowBuffer private_src;
119
+ };
120
+
121
+ /// \brief Initialize the contents of a ArrowIpcSharedBuffer struct
122
+ ///
123
+ /// If NANOARROW_OK is returned, the ArrowIpcSharedBuffer takes ownership of
124
+ /// src.
125
+ ArrowErrorCode ArrowIpcSharedBufferInit(struct ArrowIpcSharedBuffer* shared,
126
+ struct ArrowBuffer* src);
127
+
128
+ /// \brief Release the caller's copy of the shared buffer
129
+ ///
130
+ /// When finished, the caller must relinquish its own copy of the shared data
131
+ /// using this function. The original buffer will continue to exist until all
132
+ /// ArrowArray objects that refer to it have also been released.
133
+ void ArrowIpcSharedBufferReset(struct ArrowIpcSharedBuffer* shared);
134
+
135
+ /// \brief Check for shared buffer thread safety
136
+ ///
137
+ /// Thread-safe shared buffers require C11 and the stdatomic.h header.
138
+ /// If either are unavailable, shared buffers are still possible but
139
+ /// the resulting arrays must not be passed to other threads to be released.
140
+ int ArrowIpcSharedBufferIsThreadSafe(void);
141
+
142
+ /// \brief Decoder for Arrow IPC messages
143
+ ///
144
+ /// This structure is intended to be allocated by the caller,
145
+ /// initialized using ArrowIpcDecoderInit(), and released with
146
+ /// ArrowIpcDecoderReset(). These fields should not be modified
147
+ /// by the caller but can be read following a call to
148
+ /// ArrowIpcDecoderPeekHeader(), ArrowIpcDecoderVerifyHeader(), or
149
+ /// ArrowIpcDecoderDecodeHeader().
150
+ struct ArrowIpcDecoder {
151
+ /// \brief The last verified or decoded message type
152
+ enum ArrowIpcMessageType message_type;
153
+
154
+ /// \brief The metadata version as indicated by the current schema message
155
+ enum ArrowIpcMetadataVersion metadata_version;
156
+
157
+ /// \brief Buffer endianness as indicated by the current schema message
158
+ enum ArrowIpcEndianness endianness;
159
+
160
+ /// \brief Arrow IPC Features used as indicated by the current Schema message
161
+ int32_t feature_flags;
162
+
163
+ /// \brief Compression used by the current RecordBatch message
164
+ enum ArrowIpcCompressionType codec;
165
+
166
+ /// \brief The number of bytes in the current header message
167
+ ///
168
+ /// This value includes the 8 bytes before the start of the header message
169
+ /// content and any padding bytes required to make the header message size
170
+ /// be a multiple of 8 bytes.
171
+ int32_t header_size_bytes;
172
+
173
+ /// \brief The number of bytes in the forthcoming body message.
174
+ int64_t body_size_bytes;
175
+
176
+ /// \brief Private resources managed by this library
177
+ void* private_data;
178
+ };
179
+
180
+ /// \brief Initialize a decoder
181
+ ArrowErrorCode ArrowIpcDecoderInit(struct ArrowIpcDecoder* decoder);
182
+
183
+ /// \brief Release all resources attached to a decoder
184
+ void ArrowIpcDecoderReset(struct ArrowIpcDecoder* decoder);
185
+
186
+ /// \brief Peek at a message header
187
+ ///
188
+ /// The first 8 bytes of an Arrow IPC message are 0xFFFFFF followed by the size
189
+ /// of the header as a little-endian 32-bit integer. ArrowIpcDecoderPeekHeader()
190
+ /// reads these bytes and returns ESPIPE if there are not enough remaining bytes
191
+ /// in data to read the entire header message, EINVAL if the first 8 bytes are
192
+ /// not valid, ENODATA if the Arrow end-of-stream indicator has been reached, or
193
+ /// NANOARROW_OK otherwise.
194
+ ArrowErrorCode ArrowIpcDecoderPeekHeader(struct ArrowIpcDecoder* decoder,
195
+ struct ArrowBufferView data, struct ArrowError* error);
196
+
197
+ /// \brief Verify a message header
198
+ ///
199
+ /// Runs ArrowIpcDecoderPeekHeader() to ensure data is sufficiently large but
200
+ /// additionally runs flatbuffer verification to ensure that decoding the data
201
+ /// will not access memory outside of the buffer specified by data.
202
+ /// ArrowIpcDecoderVerifyHeader() will also set decoder.header_size_bytes,
203
+ /// decoder.body_size_bytes, decoder.metadata_version, and decoder.message_type.
204
+ ///
205
+ /// Returns as ArrowIpcDecoderPeekHeader() and additionally will
206
+ /// return EINVAL if flatbuffer verification fails.
207
+ ArrowErrorCode ArrowIpcDecoderVerifyHeader(struct ArrowIpcDecoder* decoder,
208
+ struct ArrowBufferView data, struct ArrowError* error);
209
+
210
+ /// \brief Decode a message header
211
+ ///
212
+ /// Runs ArrowIpcDecoderPeekHeader() to ensure data is sufficiently large and
213
+ /// decodes the content of the message header. If data contains a schema
214
+ /// message, decoder.endianness and decoder.feature_flags is set and
215
+ /// ArrowIpcDecoderDecodeSchema() can be used to obtain the decoded schema. If
216
+ /// data contains a record batch message, decoder.codec is set and a successful
217
+ /// call can be followed by a call to ArrowIpcDecoderDecodeArray().
218
+ ///
219
+ /// In almost all cases this should be preceded by a call to
220
+ /// ArrowIpcDecoderVerifyHeader() to ensure decoding does not access data
221
+ /// outside of the specified buffer.
222
+ ///
223
+ /// Returns EINVAL if the content of the message cannot be decoded or ENOTSUP if
224
+ /// the content of the message uses features not supported by this library.
225
+ ArrowErrorCode ArrowIpcDecoderDecodeHeader(struct ArrowIpcDecoder* decoder,
226
+ struct ArrowBufferView data, struct ArrowError* error);
227
+
228
+ /// \brief Decode an ArrowSchema
229
+ ///
230
+ /// After a successful call to ArrowIpcDecoderDecodeHeader(), retrieve an
231
+ /// ArrowSchema. The caller is responsible for releasing the schema if
232
+ /// NANOARROW_OK is returned.
233
+ ///
234
+ /// Returns EINVAL if the decoder did not just decode a schema message or
235
+ /// NANOARROW_OK otherwise.
236
+ ArrowErrorCode ArrowIpcDecoderDecodeSchema(struct ArrowIpcDecoder* decoder, struct ArrowSchema* out,
237
+ struct ArrowError* error);
238
+
239
+ /// \brief Set the ArrowSchema used to decode future record batch messages
240
+ ///
241
+ /// Prepares the decoder for future record batch messages
242
+ /// of this type. The decoder takes ownership of schema if NANOARROW_OK is
243
+ /// returned. Note that you must call this explicitly after decoding a Schema
244
+ /// message (i.e., the decoder does not assume that the last-decoded schema
245
+ /// message applies to future record batch messages).
246
+ ///
247
+ /// Returns EINVAL if schema validation fails or NANOARROW_OK otherwise.
248
+ ArrowErrorCode ArrowIpcDecoderSetSchema(struct ArrowIpcDecoder* decoder, struct ArrowSchema* schema,
249
+ struct ArrowError* error);
250
+
251
+ /// \brief Set the endianness used to decode future record batch messages
252
+ ///
253
+ /// Prepares the decoder for future record batch messages with the specified
254
+ /// endianness. Note that you must call this explicitly after decoding a
255
+ /// Schema message (i.e., the decoder does not assume that the last-decoded
256
+ /// schema message applies to future record batch messages).
257
+ ///
258
+ /// Returns NANOARROW_OK on success.
259
+ ArrowErrorCode ArrowIpcDecoderSetEndianness(struct ArrowIpcDecoder* decoder,
260
+ enum ArrowIpcEndianness endianness);
261
+
262
+ /// \brief Decode an ArrowArrayView
263
+ ///
264
+ /// After a successful call to ArrowIpcDecoderDecodeHeader(), deserialize the
265
+ /// content of body into an internally-managed ArrowArrayView and return it.
266
+ /// Note that field index does not equate to column index if any columns contain
267
+ /// nested types. Use a value of -1 to decode the entire array into a struct.
268
+ /// The pointed-to ArrowArrayView is owned by the ArrowIpcDecoder and must not
269
+ /// be released.
270
+ ///
271
+ /// For streams that match system endianness and do not use compression, this
272
+ /// operation will not perform any heap allocations; however, the buffers
273
+ /// referred to by the returned ArrowArrayView are only valid as long as the
274
+ /// buffer referred to by body stays valid.
275
+ ArrowErrorCode ArrowIpcDecoderDecodeArrayView(struct ArrowIpcDecoder* decoder,
276
+ struct ArrowBufferView body, int64_t i,
277
+ struct ArrowArrayView** out,
278
+ struct ArrowError* error);
279
+
280
+ /// \brief Decode an ArrowArray
281
+ ///
282
+ /// After a successful call to ArrowIpcDecoderDecodeHeader(), assemble an
283
+ /// ArrowArray given a message body and a field index. Note that field index
284
+ /// does not equate to column index if any columns contain nested types. Use a
285
+ /// value of -1 to decode the entire array into a struct. The caller is
286
+ /// responsible for releasing the array if NANOARROW_OK is returned.
287
+ ///
288
+ /// Returns EINVAL if the decoder did not just decode a record batch message,
289
+ /// ENOTSUP if the message uses features not supported by this library, or or
290
+ /// NANOARROW_OK otherwise.
291
+ ArrowErrorCode ArrowIpcDecoderDecodeArray(struct ArrowIpcDecoder* decoder,
292
+ struct ArrowBufferView body, int64_t i,
293
+ struct ArrowArray* out,
294
+ enum ArrowValidationLevel validation_level,
295
+ struct ArrowError* error);
296
+
297
+ /// \brief Decode an ArrowArray from an owned buffer
298
+ ///
299
+ /// This implementation takes advantage of the fact that it can avoid copying
300
+ /// individual buffers. In all cases the caller must ArrowIpcSharedBufferReset()
301
+ /// body after one or more calls to ArrowIpcDecoderDecodeArrayFromShared(). If
302
+ /// ArrowIpcSharedBufferIsThreadSafe() returns 0, out must not be released by
303
+ /// another thread.
304
+ ArrowErrorCode ArrowIpcDecoderDecodeArrayFromShared(struct ArrowIpcDecoder* decoder,
305
+ struct ArrowIpcSharedBuffer* shared, int64_t i,
306
+ struct ArrowArray* out,
307
+ enum ArrowValidationLevel validation_level,
308
+ struct ArrowError* error);
309
+
310
+ /// \brief An user-extensible input data source
311
+ struct ArrowIpcInputStream {
312
+ /// \brief Read up to buf_size_bytes from stream into buf
313
+ ///
314
+ /// The actual number of bytes read is placed in the value pointed to by
315
+ /// size_read_out. Returns NANOARROW_OK on success.
316
+ ArrowErrorCode (*read)(struct ArrowIpcInputStream* stream, uint8_t* buf, int64_t buf_size_bytes,
317
+ int64_t* size_read_out, struct ArrowError* error);
318
+
319
+ /// \brief Release the stream and any resources it may be holding
320
+ ///
321
+ /// Release callback implementations must set the release member to NULL.
322
+ /// Callers must check that the release callback is not NULL before calling
323
+ /// read() or release().
324
+ void (*release)(struct ArrowIpcInputStream* stream);
325
+
326
+ /// \brief Private implementation-defined data
327
+ void* private_data;
328
+ };
329
+
330
+ /// \brief Transfer ownership of an ArrowIpcInputStream
331
+ void ArrowIpcInputStreamMove(struct ArrowIpcInputStream* src, struct ArrowIpcInputStream* dst);
332
+
333
+ /// \brief Create an input stream from an ArrowBuffer
334
+ ArrowErrorCode ArrowIpcInputStreamInitBuffer(struct ArrowIpcInputStream* stream,
335
+ struct ArrowBuffer* input);
336
+
337
+ /// \brief Create an input stream from a C FILE* pointer
338
+ ///
339
+ /// Note that the ArrowIpcInputStream has no mechanism to communicate an error
340
+ /// if file_ptr fails to close. If this behaviour is needed, pass false to
341
+ /// close_on_release and handle closing the file independently from stream.
342
+ ArrowErrorCode ArrowIpcInputStreamInitFile(struct ArrowIpcInputStream* stream, void* file_ptr,
343
+ int close_on_release);
344
+
345
+ /// \brief Options for ArrowIpcArrayStreamReaderInit()
346
+ struct ArrowIpcArrayStreamReaderOptions {
347
+ /// \brief The field index to extract.
348
+ ///
349
+ /// Defaults to -1 (i.e., read all fields). Note that this field index refers
350
+ /// to the flattened tree of children and not necessarily the column index.
351
+ int64_t field_index;
352
+
353
+ /// \brief Set to a non-zero value to share the message body buffer among
354
+ /// decoded arrays
355
+ ///
356
+ /// Sharing buffers is a good choice when (1) using memory-mapped IO
357
+ /// (since unreferenced portions of the file are often not loaded into memory)
358
+ /// or (2) if all data from all columns are about to be referenced anyway.
359
+ /// When loading a single field there is probably no advantage to using shared
360
+ /// buffers. Defaults to the value of ArrowIpcSharedBufferIsThreadSafe().
361
+ int use_shared_buffers;
362
+ };
363
+
364
+ /// \brief Initialize an ArrowArrayStream from an input stream of bytes
365
+ ///
366
+ /// The stream of bytes must begin with a Schema message and be followed by
367
+ /// zero or more RecordBatch messages as described in the Arrow IPC stream
368
+ /// format specification. Returns NANOARROW_OK on success. If NANOARROW_OK
369
+ /// is returned, the ArrowArrayStream takes ownership of input_stream and
370
+ /// the caller is responsible for releasing out.
371
+ ArrowErrorCode ArrowIpcArrayStreamReaderInit(struct ArrowArrayStream* out,
372
+ struct ArrowIpcInputStream* input_stream,
373
+ struct ArrowIpcArrayStreamReaderOptions* options);
374
+
375
+ /// @}
376
+
377
+ #ifdef __cplusplus
378
+ }
379
+ #endif
380
+
381
+ #endif
@@ -0,0 +1,108 @@
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._internal.logging.native_extension_logger", pyLoggingModule);
21
+ PyObject* logger = PyObject_CallMethod(pyLoggingModule.get(), "get_native_extension_logger", "s", m_name);
22
+
23
+ m_pyLogger.reset(logger);
24
+ }
25
+
26
+ Logger::Logger(const char* name) : m_name(name) {}
27
+
28
+ void Logger::log(int level, const char* path_name, const char* func_name, int line_num,
29
+ const char* msg) {
30
+ auto initialize = [this]() {
31
+ py::PyUniqueLock lock;
32
+ setupPyLogger();
33
+ };
34
+ if (PyGILState_Check()) {
35
+ Py_BEGIN_ALLOW_THREADS
36
+ std::call_once(m_initOnceFlag, initialize);
37
+ Py_END_ALLOW_THREADS
38
+ } else {
39
+ std::call_once(m_initOnceFlag, initialize);
40
+ }
41
+
42
+ py::PyUniqueLock lock;
43
+ PyObject* logger = m_pyLogger.get();
44
+ py::UniqueRef keywords(PyDict_New());
45
+ py::UniqueRef call_log(PyObject_GetAttrString(logger, "log"));
46
+
47
+ // prepare keyword args for native_extension_logger
48
+ py::UniqueRef level_ref(Py_BuildValue("i", level));
49
+ py::UniqueRef path_name_ref(Py_BuildValue("s", path_name));
50
+ py::UniqueRef func_name_ref(Py_BuildValue("s", func_name));
51
+ py::UniqueRef line_num_ref(Py_BuildValue("i", line_num));
52
+ py::UniqueRef msg_ref(Py_BuildValue("s", msg));
53
+
54
+ PyDict_SetItemString(keywords.get(), "level", level_ref.get());
55
+ PyDict_SetItemString(keywords.get(), "path_name", path_name_ref.get());
56
+ PyDict_SetItemString(keywords.get(), "func_name", func_name_ref.get());
57
+ PyDict_SetItemString(keywords.get(), "line_num", line_num_ref.get());
58
+ PyDict_SetItemString(keywords.get(), "msg", msg_ref.get());
59
+
60
+ // call native_extension_logger.NativeExtensionLogger.log()
61
+ PyObject_Call(call_log.get(), Py_BuildValue("()"), keywords.get());
62
+ }
63
+
64
+ void Logger::debug(const char* path_name, const char* func_name, int line_num, const char* format,
65
+ ...) {
66
+ char msg[1000] = {0};
67
+ va_list args;
68
+ va_start(args, format);
69
+ vsnprintf(msg, sizeof(msg), format, args);
70
+ va_end(args);
71
+
72
+ Logger::log(DEBUG, path_name, func_name, line_num, msg);
73
+ }
74
+
75
+ void Logger::info(const char* path_name, const char* func_name, int line_num, const char* format,
76
+ ...) {
77
+ char msg[1000] = {0};
78
+ va_list args;
79
+ va_start(args, format);
80
+ vsnprintf(msg, sizeof(msg), format, args);
81
+ va_end(args);
82
+
83
+ Logger::log(INFO, path_name, func_name, line_num, msg);
84
+ }
85
+
86
+ void Logger::warn(const char* path_name, const char* func_name, int line_num, const char* format,
87
+ ...) {
88
+ char msg[1000] = {0};
89
+ va_list args;
90
+ va_start(args, format);
91
+ vsnprintf(msg, sizeof(msg), format, args);
92
+ va_end(args);
93
+
94
+ Logger::log(WARN, path_name, func_name, line_num, msg);
95
+ }
96
+
97
+ void Logger::error(const char* path_name, const char* func_name, int line_num, const char* format,
98
+ ...) {
99
+ char msg[1000] = {0};
100
+ va_list args;
101
+ va_start(args, format);
102
+ vsnprintf(msg, sizeof(msg), format, args);
103
+ va_end(args);
104
+
105
+ Logger::log(ERROR, path_name, func_name, line_num, msg);
106
+ }
107
+
108
+ } // namespace sf
@@ -0,0 +1,47 @@
1
+ #ifndef PC_LOGGING_HPP
2
+ #define PC_LOGGING_HPP
3
+
4
+ #include <mutex>
5
+ #include <string>
6
+
7
+ #include "Python/Common.hpp"
8
+
9
+ namespace sf {
10
+
11
+ class Logger {
12
+ public:
13
+ explicit Logger(const char* name);
14
+
15
+ void log(int level, const char* path_name, const char* func_name, int line_num, const char* msg);
16
+
17
+ void debug(const char* path_name, const char* func_name, int line_num, const char* format, ...);
18
+
19
+ void info(const char* path_name, const char* func_name, int line_num, const char* format, ...);
20
+
21
+ void warn(const char* path_name, const char* func_name, int line_num, const char* format, ...);
22
+
23
+ void error(const char* path_name, const char* func_name, int line_num, const char* format, ...);
24
+
25
+ static std::string formatString(const char* fmt, ...);
26
+
27
+ private:
28
+ py::UniqueRef m_pyLogger;
29
+ // setupPyLogger assigns m_pyLogger; two threads can both observe it unset.
30
+ std::once_flag m_initOnceFlag;
31
+ const char* const m_name;
32
+ static constexpr int CRITICAL = 50;
33
+ static constexpr int FATAL = CRITICAL;
34
+ static constexpr int ERROR = 40;
35
+ static constexpr int WARNING = 30;
36
+ static constexpr int WARN = WARNING;
37
+ static constexpr int INFO = 20;
38
+ static constexpr int DEBUG = 10;
39
+ static constexpr int NOTSET = 0;
40
+ static constexpr int LINE_NUM = 0;
41
+
42
+ void setupPyLogger();
43
+ };
44
+
45
+ } // namespace sf
46
+
47
+ #endif // PC_LOGGING_HPP
@@ -0,0 +1,8 @@
1
+ BasedOnStyle: Google
2
+ AccessModifierOffset: -2
3
+ BreakBeforeBraces: Allman
4
+ ConstructorInitializerIndentWidth: 0
5
+ IndentCaseLabels: true
6
+ IndentWidth: 2
7
+ NamespaceIndentation: None
8
+ PointerBindsToType: true
@@ -0,0 +1,8 @@
1
+ #!/bin/bash
2
+
3
+ THIS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
4
+
5
+ find $THIS_DIR/.. -iname *.h -o -iname *.c -o -iname *.cpp -o -iname *.hpp \
6
+ | xargs clang-format -style=file -i
7
+
8
+ exit 0
File without changes