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.
- snowflake/connector/__init__.py +148 -0
- snowflake/connector/_common/__init__.py +0 -0
- snowflake/connector/_common/extras.py +134 -0
- snowflake/connector/_common/telemetry.py +221 -0
- snowflake/connector/_common/wif_util.py +92 -0
- snowflake/connector/_core/sf_core_python.cp315-win_amd64.pyd +0 -0
- snowflake/connector/_core/sf_core_python.pyi +79 -0
- snowflake/connector/_internal/__init__.py +6 -0
- snowflake/connector/_internal/_private_key_helper.py +31 -0
- snowflake/connector/_internal/api_client/__init__.py +93 -0
- snowflake/connector/_internal/api_client/bridge.py +41 -0
- snowflake/connector/_internal/api_client/client_api.py +976 -0
- snowflake/connector/_internal/arrow.py +47 -0
- snowflake/connector/_internal/arrow_context.py +240 -0
- snowflake/connector/_internal/arrow_stream_async.py +266 -0
- snowflake/connector/_internal/arrow_stream_iterator.cp311-win_amd64.pyd +0 -0
- snowflake/connector/_internal/arrow_stream_iterator.cp312-win_amd64.pyd +0 -0
- snowflake/connector/_internal/arrow_stream_iterator.cp313-win_amd64.pyd +0 -0
- snowflake/connector/_internal/arrow_stream_iterator.cp314-win_amd64.pyd +0 -0
- snowflake/connector/_internal/arrow_stream_iterator.cp314t-win_amd64.pyd +0 -0
- snowflake/connector/_internal/arrow_stream_iterator.cp315-win_amd64.pyd +0 -0
- snowflake/connector/_internal/arrow_stream_iterator.pyi +42 -0
- snowflake/connector/_internal/arrow_stream_utils.py +171 -0
- snowflake/connector/_internal/authenticator_type.py +53 -0
- snowflake/connector/_internal/backward_compatibility.py +245 -0
- snowflake/connector/_internal/binding_converters.py +741 -0
- snowflake/connector/_internal/config_utils.py +71 -0
- snowflake/connector/_internal/connection/__init__.py +39 -0
- snowflake/connector/_internal/connection/connection.py +616 -0
- snowflake/connector/_internal/connection/connection_types.py +13 -0
- snowflake/connector/_internal/connection/constants.py +25 -0
- snowflake/connector/_internal/connection/decorators.py +31 -0
- snowflake/connector/_internal/connection/freezable_proxy.py +104 -0
- snowflake/connector/_internal/connection/queries.py +10 -0
- snowflake/connector/_internal/connection_config_mixin.py +755 -0
- snowflake/connector/_internal/cursor/__init__.py +25 -0
- snowflake/connector/_internal/cursor/base.py +732 -0
- snowflake/connector/_internal/cursor/cursor_types.py +13 -0
- snowflake/connector/_internal/cursor/decorators.py +56 -0
- snowflake/connector/_internal/cursor/query_result.py +202 -0
- snowflake/connector/_internal/cursor/query_result_waiter.py +98 -0
- snowflake/connector/_internal/cursor/result_metadata.py +255 -0
- snowflake/connector/_internal/cursor/result_set_wrapper.py +66 -0
- snowflake/connector/_internal/decorators.py +539 -0
- snowflake/connector/_internal/error_kinds.py +111 -0
- snowflake/connector/_internal/errorcode.py +35 -0
- snowflake/connector/_internal/errorhandler.py +278 -0
- snowflake/connector/_internal/fips.py +28 -0
- snowflake/connector/_internal/logging/__init__.py +52 -0
- snowflake/connector/_internal/logging/config.py +134 -0
- snowflake/connector/_internal/logging/core_logger.py +218 -0
- snowflake/connector/_internal/logging/native_extension_logger.py +144 -0
- snowflake/connector/_internal/logout_config_mapping.py +187 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/ArrayConverter.cpp +57 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/ArrayConverter.hpp +29 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/ArrowTableConverter.cpp +943 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/ArrowTableConverter.hpp +63 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/BinaryConverter.cpp +18 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/BinaryConverter.hpp +26 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/BooleanConverter.cpp +21 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/BooleanConverter.hpp +23 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/CArrowIterator.cpp +118 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/CArrowIterator.hpp +116 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/CArrowStreamIterator.cpp +323 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/CArrowStreamIterator.hpp +133 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/CArrowStreamTableIterator.cpp +275 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/CArrowStreamTableIterator.hpp +168 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/ConverterUtil.cpp +439 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/ConverterUtil.hpp +30 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/DateConverter.cpp +48 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/DateConverter.hpp +46 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/DecFloatConverter.cpp +76 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/DecFloatConverter.hpp +35 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/DecimalConverter.cpp +90 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/DecimalConverter.hpp +63 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/FixedSizeListConverter.cpp +62 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/FixedSizeListConverter.hpp +28 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/FloatConverter.cpp +29 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/FloatConverter.hpp +35 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/IColumnConverter.hpp +17 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/IntConverter.cpp +23 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/IntConverter.hpp +41 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/IntervalConverter.cpp +65 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/IntervalConverter.hpp +54 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/LICENSE.txt +209 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/MapConverter.cpp +79 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/MapConverter.hpp +30 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/ObjectConverter.cpp +52 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/ObjectConverter.hpp +29 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/Python/Common.cpp +8 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/Python/Common.hpp +117 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/Python/Helpers.cpp +54 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/Python/Helpers.hpp +34 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/SnowflakeType.cpp +33 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/SnowflakeType.hpp +48 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/StringConverter.cpp +18 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/StringConverter.hpp +26 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/TimeConverter.cpp +39 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/TimeConverter.hpp +31 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/TimeStampConverter.cpp +326 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/TimeStampConverter.hpp +138 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/Util/macros.hpp +14 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/Util/time.cpp +65 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/Util/time.hpp +68 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/arrow_stream_iterator.cpp +13278 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/arrow_stream_iterator.pyx +204 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_accessors.h +109 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_alloc.h +125 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_assert.h +45 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_builder.h +1914 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_emitter.h +208 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_endian.h +128 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_epilogue.h +7 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_flatbuffers.h +58 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_identifier.h +144 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_iov.h +31 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_prologue.h +8 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_refmap.h +144 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_rtconfig.h +160 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_types.h +98 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_verifier.h +243 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/portable/flatcc_portable.h +14 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/portable/paligned_alloc.h +207 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/portable/pattributes.h +80 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/portable/pdiagnostic.h +83 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/portable/pdiagnostic_pop.h +20 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/portable/pdiagnostic_push.h +51 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/portable/pendian.h +201 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/portable/pendian_detect.h +108 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/portable/pinline.h +19 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/portable/pinttypes.h +52 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/portable/portable.h +2 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/portable/portable_basic.h +25 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/portable/pstatic_assert.h +67 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/portable/pstdalign.h +164 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/portable/pstdint.h +926 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/portable/punaligned.h +182 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/portable/pversion.h +6 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc/portable/pwarnings.h +52 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/flatcc.c +3052 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/nanoarrow.c +3019 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/nanoarrow.h +3354 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/nanoarrow.hpp +344 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/nanoarrow_ipc.c +29305 -0
- snowflake/connector/_internal/nanoarrow_cpp/ArrowIterator/nanoarrow_ipc.h +381 -0
- snowflake/connector/_internal/nanoarrow_cpp/Logging/logging.cpp +108 -0
- snowflake/connector/_internal/nanoarrow_cpp/Logging/logging.hpp +47 -0
- snowflake/connector/_internal/nanoarrow_cpp/scripts/.clang-format +8 -0
- snowflake/connector/_internal/nanoarrow_cpp/scripts/format.sh +8 -0
- snowflake/connector/_internal/protobuf_gen/__init__.py +0 -0
- snowflake/connector/_internal/protobuf_gen/database_driver_v1_pb2.py +408 -0
- snowflake/connector/_internal/protobuf_gen/database_driver_v1_pb2.pyi +4487 -0
- snowflake/connector/_internal/protobuf_gen/database_driver_v1_services.py +2088 -0
- snowflake/connector/_internal/protobuf_gen/proto_exception.py +17 -0
- snowflake/connector/_internal/result_batch.py +150 -0
- snowflake/connector/_internal/snowflake_restful.py +222 -0
- snowflake/connector/_internal/snowpark_backcompat_helpers.py +31 -0
- snowflake/connector/_internal/sqlstate.py +11 -0
- snowflake/connector/_internal/statement_utils.py +207 -0
- snowflake/connector/_internal/text_utils.py +112 -0
- snowflake/connector/_internal/type_codes.py +139 -0
- snowflake/connector/_internal/utils.py +65 -0
- snowflake/connector/_internal/write_pandas_operation.py +657 -0
- snowflake/connector/aio/README.md +168 -0
- snowflake/connector/aio/__init__.py +37 -0
- snowflake/connector/aio/connection/__init__.py +17 -0
- snowflake/connector/aio/connection/_connection.py +506 -0
- snowflake/connector/aio/cursor/__init__.py +35 -0
- snowflake/connector/aio/cursor/_base.py +1034 -0
- snowflake/connector/aio/cursor/_dict_cursor.py +78 -0
- snowflake/connector/aio/cursor/_result_set_wrapper.py +35 -0
- snowflake/connector/aio/cursor/_snowflake_cursor.py +72 -0
- snowflake/connector/aio/pandas_tools.py +279 -0
- snowflake/connector/aio/result_batch.py +165 -0
- snowflake/connector/auth/__init__.py +0 -0
- snowflake/connector/auth/workload_identity.py +5 -0
- snowflake/connector/compat.py +22 -0
- snowflake/connector/config_manager.py +392 -0
- snowflake/connector/connection/__init__.py +30 -0
- snowflake/connector/connection/_connection.py +641 -0
- snowflake/connector/connection_config.py +517 -0
- snowflake/connector/constants.py +52 -0
- snowflake/connector/cursor/__init__.py +37 -0
- snowflake/connector/cursor/_base.py +1169 -0
- snowflake/connector/cursor/_chunked_download_reader.py +75 -0
- snowflake/connector/cursor/_dict_cursor.py +78 -0
- snowflake/connector/cursor/_result_set_wrapper.py +35 -0
- snowflake/connector/cursor/_snowflake_cursor.py +72 -0
- snowflake/connector/description.py +7 -0
- snowflake/connector/errors.py +492 -0
- snowflake/connector/network.py +71 -0
- snowflake/connector/pandas_tools.py +191 -0
- snowflake/connector/py.typed +0 -0
- snowflake/connector/result_batch.py +216 -0
- snowflake/connector/telemetry.py +40 -0
- snowflake/connector/time_util.py +11 -0
- snowflake/connector/types.py +134 -0
- snowflake/connector/util_text.py +3 -0
- snowflake/connector/version.py +23 -0
- snowflake_connector_python-5.2.0.dist-info/DELVEWHEEL +2 -0
- snowflake_connector_python-5.2.0.dist-info/METADATA +190 -0
- snowflake_connector_python-5.2.0.dist-info/RECORD +204 -0
- snowflake_connector_python-5.2.0.dist-info/WHEEL +4 -0
- snowflake_connector_python.libs/msvcp140-a4c2229bdc2a2a630acdc095b4d86008.dll +0 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
#ifndef PC_SNOWFLAKETYPE_HPP
|
|
2
|
+
#define PC_SNOWFLAKETYPE_HPP
|
|
3
|
+
|
|
4
|
+
#include <algorithm>
|
|
5
|
+
#include <cstdint>
|
|
6
|
+
#include <string>
|
|
7
|
+
#include <unordered_map>
|
|
8
|
+
|
|
9
|
+
namespace sf {
|
|
10
|
+
|
|
11
|
+
class SnowflakeType {
|
|
12
|
+
public:
|
|
13
|
+
enum class Type : uint8_t {
|
|
14
|
+
ANY = 0,
|
|
15
|
+
ARRAY = 1,
|
|
16
|
+
BINARY = 2,
|
|
17
|
+
BOOLEAN = 3,
|
|
18
|
+
CHAR = 4,
|
|
19
|
+
DATE = 5,
|
|
20
|
+
FIXED = 6,
|
|
21
|
+
OBJECT = 7,
|
|
22
|
+
REAL = 8,
|
|
23
|
+
TEXT = 9,
|
|
24
|
+
TIME = 10,
|
|
25
|
+
TIMESTAMP = 11,
|
|
26
|
+
TIMESTAMP_LTZ = 12,
|
|
27
|
+
TIMESTAMP_NTZ = 13,
|
|
28
|
+
TIMESTAMP_TZ = 14,
|
|
29
|
+
VARIANT = 15,
|
|
30
|
+
VECTOR = 16,
|
|
31
|
+
MAP = 17,
|
|
32
|
+
DECFLOAT = 18,
|
|
33
|
+
INTERVAL_YEAR_MONTH = 19,
|
|
34
|
+
INTERVAL_DAY_TIME = 20,
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
static SnowflakeType::Type snowflakeTypeFromString(std::string str) {
|
|
38
|
+
std::transform(str.begin(), str.end(), str.begin(), ::toupper);
|
|
39
|
+
return m_strEnumIndex.at(str);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
private:
|
|
43
|
+
static std::unordered_map<std::string, SnowflakeType::Type> m_strEnumIndex;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
} // namespace sf
|
|
47
|
+
|
|
48
|
+
#endif // PC_SNOWFLAKETYPE_HPP
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#include "StringConverter.hpp"
|
|
2
|
+
|
|
3
|
+
#include <memory>
|
|
4
|
+
|
|
5
|
+
namespace sf {
|
|
6
|
+
Logger* StringConverter::logger = new Logger("snowflake.connector.StringConverter");
|
|
7
|
+
|
|
8
|
+
StringConverter::StringConverter(ArrowArrayView* array) : m_array(array) {}
|
|
9
|
+
|
|
10
|
+
PyObject* StringConverter::toPyObject(int64_t rowIndex) const {
|
|
11
|
+
if (ArrowArrayViewIsNull(m_array, rowIndex)) {
|
|
12
|
+
Py_RETURN_NONE;
|
|
13
|
+
}
|
|
14
|
+
ArrowStringView stringView = ArrowArrayViewGetStringUnsafe(m_array, rowIndex);
|
|
15
|
+
return PyUnicode_FromStringAndSize(stringView.data, stringView.size_bytes);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
} // namespace sf
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#ifndef PC_STRINGCONVERTER_HPP
|
|
2
|
+
#define PC_STRINGCONVERTER_HPP
|
|
3
|
+
|
|
4
|
+
#include <memory>
|
|
5
|
+
|
|
6
|
+
#include "IColumnConverter.hpp"
|
|
7
|
+
#include "logging.hpp"
|
|
8
|
+
#include "nanoarrow.h"
|
|
9
|
+
#include "nanoarrow.hpp"
|
|
10
|
+
|
|
11
|
+
namespace sf {
|
|
12
|
+
|
|
13
|
+
class StringConverter : public IColumnConverter {
|
|
14
|
+
public:
|
|
15
|
+
explicit StringConverter(ArrowArrayView* array);
|
|
16
|
+
PyObject* toPyObject(int64_t rowIndex) const override;
|
|
17
|
+
|
|
18
|
+
private:
|
|
19
|
+
ArrowArrayView* m_array;
|
|
20
|
+
|
|
21
|
+
static Logger* logger;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
} // namespace sf
|
|
25
|
+
|
|
26
|
+
#endif // PC_STRINGCONVERTER_HPP
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
#include "TimeConverter.hpp"
|
|
2
|
+
|
|
3
|
+
#include <mutex>
|
|
4
|
+
|
|
5
|
+
namespace sf {
|
|
6
|
+
|
|
7
|
+
TimeConverter::TimeConverter(ArrowArrayView* array, int32_t scale)
|
|
8
|
+
: m_array(array), m_scale(scale) {}
|
|
9
|
+
|
|
10
|
+
PyObject* TimeConverter::toPyObject(int64_t rowIndex) const {
|
|
11
|
+
if (ArrowArrayViewIsNull(m_array, rowIndex)) {
|
|
12
|
+
Py_RETURN_NONE;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
int64_t seconds = ArrowArrayViewGetIntUnsafe(m_array, rowIndex);
|
|
16
|
+
using namespace internal;
|
|
17
|
+
py::PyUniqueLock lock;
|
|
18
|
+
return PyObject_CallFunction(
|
|
19
|
+
m_pyDatetimeTime().get(), "iiii", getHourFromSeconds(seconds, m_scale),
|
|
20
|
+
getMinuteFromSeconds(seconds, m_scale), getSecondFromSeconds(seconds, m_scale),
|
|
21
|
+
getMicrosecondFromSeconds(seconds, m_scale));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
py::UniqueRef& TimeConverter::m_pyDatetimeTime() {
|
|
25
|
+
static py::UniqueRef pyDatetimeTime;
|
|
26
|
+
// The empty check races when the GIL does not serialize this init.
|
|
27
|
+
static std::once_flag onceFlag;
|
|
28
|
+
std::call_once(onceFlag, []() {
|
|
29
|
+
py::PyUniqueLock lock;
|
|
30
|
+
py::UniqueRef pyDatetimeModule;
|
|
31
|
+
py::importPythonModule("datetime", pyDatetimeModule);
|
|
32
|
+
/** TODO : to check status here */
|
|
33
|
+
|
|
34
|
+
py::importFromModule(pyDatetimeModule, "time", pyDatetimeTime);
|
|
35
|
+
});
|
|
36
|
+
return pyDatetimeTime;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
} // namespace sf
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#ifndef PC_TIMECONVERTER_HPP
|
|
2
|
+
#define PC_TIMECONVERTER_HPP
|
|
3
|
+
|
|
4
|
+
#include <memory>
|
|
5
|
+
|
|
6
|
+
#include "IColumnConverter.hpp"
|
|
7
|
+
#include "Python/Common.hpp"
|
|
8
|
+
#include "Python/Helpers.hpp"
|
|
9
|
+
#include "Util/time.hpp"
|
|
10
|
+
#include "nanoarrow.h"
|
|
11
|
+
|
|
12
|
+
namespace sf {
|
|
13
|
+
|
|
14
|
+
class TimeConverter : public IColumnConverter {
|
|
15
|
+
public:
|
|
16
|
+
explicit TimeConverter(ArrowArrayView* array, int32_t scale);
|
|
17
|
+
|
|
18
|
+
PyObject* toPyObject(int64_t rowIndex) const override;
|
|
19
|
+
|
|
20
|
+
private:
|
|
21
|
+
/** can be arrow::Int32Array and arrow::Int64Array */
|
|
22
|
+
ArrowArrayView* m_array;
|
|
23
|
+
|
|
24
|
+
int32_t m_scale;
|
|
25
|
+
|
|
26
|
+
static py::UniqueRef& m_pyDatetimeTime();
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
} // namespace sf
|
|
30
|
+
|
|
31
|
+
#endif // PC_TIMECONVERTER_HPP
|
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
#include "TimeStampConverter.hpp"
|
|
2
|
+
|
|
3
|
+
#include <cstdint>
|
|
4
|
+
#include <cstring>
|
|
5
|
+
#include <memory>
|
|
6
|
+
#include <type_traits>
|
|
7
|
+
|
|
8
|
+
#include "Python/Helpers.hpp"
|
|
9
|
+
#include "Util/time.hpp"
|
|
10
|
+
|
|
11
|
+
template <typename T>
|
|
12
|
+
constexpr char toType() {
|
|
13
|
+
static_assert(std::is_same<T, signed char>::value || std::is_same<T, short>::value ||
|
|
14
|
+
std::is_same<T, int>::value || std::is_same<T, long>::value ||
|
|
15
|
+
std::is_same<T, long long>::value,
|
|
16
|
+
"Unknown type");
|
|
17
|
+
return std::is_same<T, signed char>::value ? 'b'
|
|
18
|
+
: std::is_same<T, short>::value ? 'h'
|
|
19
|
+
: std::is_same<T, int>::value ? 'i'
|
|
20
|
+
: std::is_same<T, long>::value ? 'l'
|
|
21
|
+
: std::is_same<T, long long>::value ? 'L'
|
|
22
|
+
// Should not get here. Error.
|
|
23
|
+
: '?';
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
template <typename T1>
|
|
27
|
+
struct FormatArgs1 {
|
|
28
|
+
char format[2];
|
|
29
|
+
constexpr FormatArgs1() : format{toType<T1>(), '\0'} {}
|
|
30
|
+
};
|
|
31
|
+
template <typename T1, typename T2>
|
|
32
|
+
struct FormatArgs2 {
|
|
33
|
+
char format[3];
|
|
34
|
+
constexpr FormatArgs2() : format{toType<T1>(), toType<T2>(), '\0'} {}
|
|
35
|
+
};
|
|
36
|
+
template <typename T1, typename T2, typename T3>
|
|
37
|
+
struct FormatArgs3 {
|
|
38
|
+
char format[4];
|
|
39
|
+
constexpr FormatArgs3() : format{toType<T1>(), toType<T2>(), toType<T3>(), '\0'} {}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
namespace sf {
|
|
43
|
+
|
|
44
|
+
Logger* TwoFieldTimeStampNTZConverter::logger =
|
|
45
|
+
new Logger("snowflake.connector.TwoFieldTimeStampNTZConverter");
|
|
46
|
+
Logger* NumpyTwoFieldTimeStampNTZConverter::logger =
|
|
47
|
+
new Logger("snowflake.connector.NumpyTwoFieldTimeStampNTZConverter");
|
|
48
|
+
Logger* TwoFieldTimeStampLTZConverter::logger =
|
|
49
|
+
new Logger("snowflake.connector.TwoFieldTimeStampLTZConverter");
|
|
50
|
+
Logger* TwoFieldTimeStampTZConverter::logger =
|
|
51
|
+
new Logger("snowflake.connector.TwoFieldTimeStampTZConverter");
|
|
52
|
+
Logger* ThreeFieldTimeStampTZConverter::logger =
|
|
53
|
+
new Logger("snowflake.connector.ThreeFieldTimeStampTZConverter");
|
|
54
|
+
|
|
55
|
+
TimeStampBaseConverter::TimeStampBaseConverter(PyObject* context, int32_t scale)
|
|
56
|
+
: m_context(context), m_scale(scale) {}
|
|
57
|
+
|
|
58
|
+
OneFieldTimeStampNTZConverter::OneFieldTimeStampNTZConverter(ArrowArrayView* array, int32_t scale,
|
|
59
|
+
PyObject* context)
|
|
60
|
+
: TimeStampBaseConverter(context, scale), m_array(array) {}
|
|
61
|
+
|
|
62
|
+
PyObject* OneFieldTimeStampNTZConverter::toPyObject(int64_t rowIndex) const {
|
|
63
|
+
if (ArrowArrayViewIsNull(m_array, rowIndex)) {
|
|
64
|
+
Py_RETURN_NONE;
|
|
65
|
+
}
|
|
66
|
+
int64_t val = ArrowArrayViewGetIntUnsafe(m_array, rowIndex);
|
|
67
|
+
internal::TimeSpec ts(val, m_scale);
|
|
68
|
+
|
|
69
|
+
static constexpr FormatArgs2<decltype(ts.seconds), decltype(ts.microseconds)> format;
|
|
70
|
+
#ifdef _WIN32
|
|
71
|
+
return PyObject_CallMethod(m_context, "TIMESTAMP_NTZ_to_python_windows", format.format,
|
|
72
|
+
ts.seconds, ts.microseconds);
|
|
73
|
+
#else
|
|
74
|
+
return PyObject_CallMethod(m_context, "TIMESTAMP_NTZ_to_python", format.format, ts.seconds,
|
|
75
|
+
ts.microseconds);
|
|
76
|
+
#endif
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
NumpyOneFieldTimeStampNTZConverter::NumpyOneFieldTimeStampNTZConverter(ArrowArrayView* array,
|
|
80
|
+
int32_t scale,
|
|
81
|
+
PyObject* context)
|
|
82
|
+
: TimeStampBaseConverter(context, scale), m_array(array) {}
|
|
83
|
+
|
|
84
|
+
PyObject* NumpyOneFieldTimeStampNTZConverter::toPyObject(int64_t rowIndex) const {
|
|
85
|
+
if (ArrowArrayViewIsNull(m_array, rowIndex)) {
|
|
86
|
+
Py_RETURN_NONE;
|
|
87
|
+
}
|
|
88
|
+
int64_t val = ArrowArrayViewGetIntUnsafe(m_array, rowIndex);
|
|
89
|
+
return PyObject_CallMethod(m_context, "TIMESTAMP_NTZ_ONE_FIELD_to_numpy_datetime64", "Li", val,
|
|
90
|
+
m_scale);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
TwoFieldTimeStampNTZConverter::TwoFieldTimeStampNTZConverter(ArrowArrayView* array,
|
|
94
|
+
ArrowSchemaView* schema, int32_t scale,
|
|
95
|
+
PyObject* context)
|
|
96
|
+
: TimeStampBaseConverter(context, scale), m_array(array) {
|
|
97
|
+
if (schema->schema->n_children != 2) {
|
|
98
|
+
std::string errorInfo = Logger::formatString(
|
|
99
|
+
"[Snowflake Exception] arrow schema field number does not match, "
|
|
100
|
+
"expected 2 but got %d instead",
|
|
101
|
+
schema->schema->n_children);
|
|
102
|
+
logger->error(__FILE__, __func__, __LINE__, errorInfo.c_str());
|
|
103
|
+
PyErr_SetString(PyExc_Exception, errorInfo.c_str());
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
for (int i = 0; i < schema->schema->n_children; i += 1) {
|
|
107
|
+
ArrowSchema* c_schema = schema->schema->children[i];
|
|
108
|
+
if (std::strcmp(c_schema->name, internal::FIELD_NAME_EPOCH.c_str()) == 0) {
|
|
109
|
+
m_epoch = m_array->children[i];
|
|
110
|
+
} else if (std::strcmp(c_schema->name, internal::FIELD_NAME_FRACTION.c_str()) == 0) {
|
|
111
|
+
m_fraction = m_array->children[i];
|
|
112
|
+
} else {
|
|
113
|
+
// do nothing
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
PyObject* TwoFieldTimeStampNTZConverter::toPyObject(int64_t rowIndex) const {
|
|
119
|
+
if (ArrowArrayViewIsNull(m_array, rowIndex)) {
|
|
120
|
+
Py_RETURN_NONE;
|
|
121
|
+
}
|
|
122
|
+
int64_t seconds = ArrowArrayViewGetIntUnsafe(m_epoch, rowIndex);
|
|
123
|
+
int64_t microseconds = ArrowArrayViewGetIntUnsafe(m_fraction, rowIndex) / 1000;
|
|
124
|
+
|
|
125
|
+
static constexpr FormatArgs2<decltype(seconds), decltype(microseconds)> format;
|
|
126
|
+
#ifdef _WIN32
|
|
127
|
+
return PyObject_CallMethod(m_context, "TIMESTAMP_NTZ_to_python_windows", format.format, seconds,
|
|
128
|
+
microseconds);
|
|
129
|
+
#else
|
|
130
|
+
return PyObject_CallMethod(m_context, "TIMESTAMP_NTZ_to_python", format.format, seconds,
|
|
131
|
+
microseconds);
|
|
132
|
+
#endif
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
NumpyTwoFieldTimeStampNTZConverter::NumpyTwoFieldTimeStampNTZConverter(ArrowArrayView* array,
|
|
136
|
+
ArrowSchemaView* schema,
|
|
137
|
+
int32_t scale,
|
|
138
|
+
PyObject* context)
|
|
139
|
+
: TimeStampBaseConverter(context, scale), m_array(array) {
|
|
140
|
+
if (schema->schema->n_children != 2) {
|
|
141
|
+
std::string errorInfo = Logger::formatString(
|
|
142
|
+
"[Snowflake Exception] arrow schema field number does not match, "
|
|
143
|
+
"expected 2 but got %d instead",
|
|
144
|
+
schema->schema->n_children);
|
|
145
|
+
logger->error(__FILE__, __func__, __LINE__, errorInfo.c_str());
|
|
146
|
+
PyErr_SetString(PyExc_Exception, errorInfo.c_str());
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
for (int i = 0; i < schema->schema->n_children; i += 1) {
|
|
150
|
+
ArrowSchema* c_schema = schema->schema->children[i];
|
|
151
|
+
if (std::strcmp(c_schema->name, internal::FIELD_NAME_EPOCH.c_str()) == 0) {
|
|
152
|
+
m_epoch = m_array->children[i];
|
|
153
|
+
} else if (std::strcmp(c_schema->name, internal::FIELD_NAME_FRACTION.c_str()) == 0) {
|
|
154
|
+
m_fraction = m_array->children[i];
|
|
155
|
+
} else {
|
|
156
|
+
// do nothing
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
PyObject* NumpyTwoFieldTimeStampNTZConverter::toPyObject(int64_t rowIndex) const {
|
|
162
|
+
if (ArrowArrayViewIsNull(m_array, rowIndex)) {
|
|
163
|
+
Py_RETURN_NONE;
|
|
164
|
+
}
|
|
165
|
+
int64_t epoch = ArrowArrayViewGetIntUnsafe(m_epoch, rowIndex);
|
|
166
|
+
int32_t frac = ArrowArrayViewGetIntUnsafe(m_fraction, rowIndex);
|
|
167
|
+
return PyObject_CallMethod(m_context, "TIMESTAMP_NTZ_TWO_FIELD_to_numpy_datetime64", "Li", epoch,
|
|
168
|
+
frac);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
OneFieldTimeStampLTZConverter::OneFieldTimeStampLTZConverter(ArrowArrayView* array, int32_t scale,
|
|
172
|
+
PyObject* context)
|
|
173
|
+
: TimeStampBaseConverter(context, scale), m_array(array) {}
|
|
174
|
+
|
|
175
|
+
PyObject* OneFieldTimeStampLTZConverter::toPyObject(int64_t rowIndex) const {
|
|
176
|
+
if (ArrowArrayViewIsNull(m_array, rowIndex)) {
|
|
177
|
+
Py_RETURN_NONE;
|
|
178
|
+
}
|
|
179
|
+
int64_t val = ArrowArrayViewGetIntUnsafe(m_array, rowIndex);
|
|
180
|
+
internal::TimeSpec ts(val, m_scale);
|
|
181
|
+
|
|
182
|
+
static constexpr FormatArgs2<decltype(ts.seconds), decltype(ts.microseconds)> format;
|
|
183
|
+
|
|
184
|
+
#ifdef _WIN32
|
|
185
|
+
return PyObject_CallMethod(m_context, "TIMESTAMP_LTZ_to_python_windows", format.format,
|
|
186
|
+
ts.seconds, ts.microseconds);
|
|
187
|
+
#else
|
|
188
|
+
return PyObject_CallMethod(m_context, "TIMESTAMP_LTZ_to_python", format.format, ts.seconds,
|
|
189
|
+
ts.microseconds);
|
|
190
|
+
#endif
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
TwoFieldTimeStampLTZConverter::TwoFieldTimeStampLTZConverter(ArrowArrayView* array,
|
|
194
|
+
ArrowSchemaView* schema, int32_t scale,
|
|
195
|
+
PyObject* context)
|
|
196
|
+
: TimeStampBaseConverter(context, scale), m_array(array) {
|
|
197
|
+
if (schema->schema->n_children != 2) {
|
|
198
|
+
std::string errorInfo = Logger::formatString(
|
|
199
|
+
"[Snowflake Exception] arrow schema field number does not match, "
|
|
200
|
+
"expected 2 but got %d instead",
|
|
201
|
+
schema->schema->n_children);
|
|
202
|
+
logger->error(__FILE__, __func__, __LINE__, errorInfo.c_str());
|
|
203
|
+
PyErr_SetString(PyExc_Exception, errorInfo.c_str());
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
for (int i = 0; i < schema->schema->n_children; i += 1) {
|
|
207
|
+
ArrowSchema* c_schema = schema->schema->children[i];
|
|
208
|
+
if (std::strcmp(c_schema->name, internal::FIELD_NAME_EPOCH.c_str()) == 0) {
|
|
209
|
+
m_epoch = m_array->children[i];
|
|
210
|
+
} else if (std::strcmp(c_schema->name, internal::FIELD_NAME_FRACTION.c_str()) == 0) {
|
|
211
|
+
m_fraction = m_array->children[i];
|
|
212
|
+
} else {
|
|
213
|
+
// do nothing
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
PyObject* TwoFieldTimeStampLTZConverter::toPyObject(int64_t rowIndex) const {
|
|
219
|
+
if (ArrowArrayViewIsNull(m_array, rowIndex)) {
|
|
220
|
+
Py_RETURN_NONE;
|
|
221
|
+
}
|
|
222
|
+
int64_t seconds = ArrowArrayViewGetIntUnsafe(m_epoch, rowIndex);
|
|
223
|
+
int64_t microseconds = ArrowArrayViewGetIntUnsafe(m_fraction, rowIndex) / 1000;
|
|
224
|
+
|
|
225
|
+
static constexpr FormatArgs2<decltype(seconds), decltype(microseconds)> format;
|
|
226
|
+
#ifdef _WIN32
|
|
227
|
+
return PyObject_CallMethod(m_context, "TIMESTAMP_LTZ_to_python_windows", format.format, seconds,
|
|
228
|
+
microseconds);
|
|
229
|
+
#else
|
|
230
|
+
return PyObject_CallMethod(m_context, "TIMESTAMP_LTZ_to_python", format.format, seconds,
|
|
231
|
+
microseconds);
|
|
232
|
+
#endif
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
TwoFieldTimeStampTZConverter::TwoFieldTimeStampTZConverter(ArrowArrayView* array,
|
|
236
|
+
ArrowSchemaView* schema, int32_t scale,
|
|
237
|
+
PyObject* context)
|
|
238
|
+
: TimeStampBaseConverter(context, scale), m_array(array) {
|
|
239
|
+
if (schema->schema->n_children != 2) {
|
|
240
|
+
std::string errorInfo = Logger::formatString(
|
|
241
|
+
"[Snowflake Exception] arrow schema field number does not match, "
|
|
242
|
+
"expected 2 but got %d instead",
|
|
243
|
+
schema->schema->n_children);
|
|
244
|
+
logger->error(__FILE__, __func__, __LINE__, errorInfo.c_str());
|
|
245
|
+
PyErr_SetString(PyExc_Exception, errorInfo.c_str());
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
for (int i = 0; i < schema->schema->n_children; i += 1) {
|
|
249
|
+
ArrowSchema* c_schema = schema->schema->children[i];
|
|
250
|
+
if (std::strcmp(c_schema->name, internal::FIELD_NAME_EPOCH.c_str()) == 0) {
|
|
251
|
+
m_epoch = m_array->children[i];
|
|
252
|
+
} else if (std::strcmp(c_schema->name, internal::FIELD_NAME_TIME_ZONE.c_str()) == 0) {
|
|
253
|
+
m_timezone = m_array->children[i];
|
|
254
|
+
} else {
|
|
255
|
+
// do nothing
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
PyObject* TwoFieldTimeStampTZConverter::toPyObject(int64_t rowIndex) const {
|
|
261
|
+
if (ArrowArrayViewIsNull(m_array, rowIndex)) {
|
|
262
|
+
Py_RETURN_NONE;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
int32_t timezone = ArrowArrayViewGetIntUnsafe(m_timezone, rowIndex);
|
|
266
|
+
internal::TimeSpec ts(ArrowArrayViewGetIntUnsafe(m_epoch, rowIndex), m_scale);
|
|
267
|
+
|
|
268
|
+
static constexpr FormatArgs3<decltype(ts.seconds), decltype(ts.microseconds), decltype(timezone)>
|
|
269
|
+
format;
|
|
270
|
+
#if _WIN32
|
|
271
|
+
return PyObject_CallMethod(m_context, "TIMESTAMP_TZ_to_python_windows", format.format, ts.seconds,
|
|
272
|
+
ts.microseconds, timezone);
|
|
273
|
+
#else
|
|
274
|
+
return PyObject_CallMethod(m_context, "TIMESTAMP_TZ_to_python", format.format, ts.seconds,
|
|
275
|
+
ts.microseconds, timezone);
|
|
276
|
+
#endif
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
ThreeFieldTimeStampTZConverter::ThreeFieldTimeStampTZConverter(ArrowArrayView* array,
|
|
280
|
+
ArrowSchemaView* schema,
|
|
281
|
+
int32_t scale, PyObject* context)
|
|
282
|
+
: TimeStampBaseConverter(context, scale), m_array(array) {
|
|
283
|
+
if (schema->schema->n_children != 3) {
|
|
284
|
+
std::string errorInfo = Logger::formatString(
|
|
285
|
+
"[Snowflake Exception] arrow schema field number does not match, "
|
|
286
|
+
"expected 3 but got %d instead",
|
|
287
|
+
schema->schema->n_children);
|
|
288
|
+
logger->error(__FILE__, __func__, __LINE__, errorInfo.c_str());
|
|
289
|
+
PyErr_SetString(PyExc_Exception, errorInfo.c_str());
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
for (int i = 0; i < schema->schema->n_children; i += 1) {
|
|
293
|
+
ArrowSchema* c_schema = schema->schema->children[i];
|
|
294
|
+
if (std::strcmp(c_schema->name, internal::FIELD_NAME_EPOCH.c_str()) == 0) {
|
|
295
|
+
m_epoch = m_array->children[i];
|
|
296
|
+
} else if (std::strcmp(c_schema->name, internal::FIELD_NAME_TIME_ZONE.c_str()) == 0) {
|
|
297
|
+
m_timezone = m_array->children[i];
|
|
298
|
+
} else if (std::strcmp(c_schema->name, internal::FIELD_NAME_FRACTION.c_str()) == 0) {
|
|
299
|
+
m_fraction = m_array->children[i];
|
|
300
|
+
} else {
|
|
301
|
+
// do nothing
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
PyObject* ThreeFieldTimeStampTZConverter::toPyObject(int64_t rowIndex) const {
|
|
307
|
+
if (ArrowArrayViewIsNull(m_array, rowIndex)) {
|
|
308
|
+
Py_RETURN_NONE;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
int32_t timezone = ArrowArrayViewGetIntUnsafe(m_timezone, rowIndex);
|
|
312
|
+
int64_t seconds = ArrowArrayViewGetIntUnsafe(m_epoch, rowIndex);
|
|
313
|
+
int64_t microseconds = ArrowArrayViewGetIntUnsafe(m_fraction, rowIndex) / 1000;
|
|
314
|
+
|
|
315
|
+
static constexpr FormatArgs3<decltype(seconds), decltype(microseconds), decltype(timezone)>
|
|
316
|
+
format;
|
|
317
|
+
#ifdef _WIN32
|
|
318
|
+
return PyObject_CallMethod(m_context, "TIMESTAMP_TZ_to_python_windows", format.format, seconds,
|
|
319
|
+
microseconds, timezone);
|
|
320
|
+
#else
|
|
321
|
+
return PyObject_CallMethod(m_context, "TIMESTAMP_TZ_to_python", format.format, seconds,
|
|
322
|
+
microseconds, timezone);
|
|
323
|
+
#endif
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
} // namespace sf
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
#ifndef PC_TIMESTAMPCONVERTER_HPP
|
|
2
|
+
#define PC_TIMESTAMPCONVERTER_HPP
|
|
3
|
+
|
|
4
|
+
#include <memory>
|
|
5
|
+
|
|
6
|
+
#include "IColumnConverter.hpp"
|
|
7
|
+
#include "Python/Common.hpp"
|
|
8
|
+
#include "Python/Helpers.hpp"
|
|
9
|
+
#include "Util/time.hpp"
|
|
10
|
+
#include "logging.hpp"
|
|
11
|
+
#include "nanoarrow.h"
|
|
12
|
+
|
|
13
|
+
namespace sf {
|
|
14
|
+
|
|
15
|
+
// correspond to python datetime.time and datetime.time has only support 6 bit
|
|
16
|
+
// precision, which is millisecond
|
|
17
|
+
|
|
18
|
+
class TimeStampBaseConverter : public IColumnConverter {
|
|
19
|
+
public:
|
|
20
|
+
TimeStampBaseConverter(PyObject* context, int32_t scale);
|
|
21
|
+
virtual ~TimeStampBaseConverter() = default;
|
|
22
|
+
|
|
23
|
+
protected:
|
|
24
|
+
PyObject* m_context;
|
|
25
|
+
|
|
26
|
+
int32_t m_scale;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
class OneFieldTimeStampNTZConverter : public TimeStampBaseConverter {
|
|
30
|
+
public:
|
|
31
|
+
explicit OneFieldTimeStampNTZConverter(ArrowArrayView* array, int32_t scale, PyObject* context);
|
|
32
|
+
|
|
33
|
+
PyObject* toPyObject(int64_t rowIndex) const override;
|
|
34
|
+
|
|
35
|
+
private:
|
|
36
|
+
ArrowArrayView* m_array;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
class NumpyOneFieldTimeStampNTZConverter : public TimeStampBaseConverter {
|
|
40
|
+
public:
|
|
41
|
+
explicit NumpyOneFieldTimeStampNTZConverter(ArrowArrayView* array, int32_t scale,
|
|
42
|
+
PyObject* context);
|
|
43
|
+
|
|
44
|
+
PyObject* toPyObject(int64_t rowIndex) const override;
|
|
45
|
+
|
|
46
|
+
private:
|
|
47
|
+
ArrowArrayView* m_array;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
class TwoFieldTimeStampNTZConverter : public TimeStampBaseConverter {
|
|
51
|
+
public:
|
|
52
|
+
explicit TwoFieldTimeStampNTZConverter(ArrowArrayView* array, ArrowSchemaView* schema,
|
|
53
|
+
int32_t scale, PyObject* context);
|
|
54
|
+
|
|
55
|
+
PyObject* toPyObject(int64_t rowIndex) const override;
|
|
56
|
+
|
|
57
|
+
private:
|
|
58
|
+
ArrowArrayView* m_array;
|
|
59
|
+
ArrowArrayView* m_epoch;
|
|
60
|
+
ArrowArrayView* m_fraction;
|
|
61
|
+
|
|
62
|
+
static Logger* logger;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
class NumpyTwoFieldTimeStampNTZConverter : public TimeStampBaseConverter {
|
|
66
|
+
public:
|
|
67
|
+
explicit NumpyTwoFieldTimeStampNTZConverter(ArrowArrayView* array, ArrowSchemaView* schema,
|
|
68
|
+
int32_t scale, PyObject* context);
|
|
69
|
+
|
|
70
|
+
PyObject* toPyObject(int64_t rowIndex) const override;
|
|
71
|
+
|
|
72
|
+
private:
|
|
73
|
+
ArrowArrayView* m_array;
|
|
74
|
+
ArrowArrayView* m_epoch;
|
|
75
|
+
ArrowArrayView* m_fraction;
|
|
76
|
+
|
|
77
|
+
static Logger* logger;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
class OneFieldTimeStampLTZConverter : public TimeStampBaseConverter {
|
|
81
|
+
public:
|
|
82
|
+
explicit OneFieldTimeStampLTZConverter(ArrowArrayView* array, int32_t scale, PyObject* context);
|
|
83
|
+
|
|
84
|
+
PyObject* toPyObject(int64_t rowIndex) const override;
|
|
85
|
+
|
|
86
|
+
private:
|
|
87
|
+
ArrowArrayView* m_array;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
class TwoFieldTimeStampLTZConverter : public TimeStampBaseConverter {
|
|
91
|
+
public:
|
|
92
|
+
explicit TwoFieldTimeStampLTZConverter(ArrowArrayView* array, ArrowSchemaView* schema,
|
|
93
|
+
int32_t scale, PyObject* context);
|
|
94
|
+
|
|
95
|
+
PyObject* toPyObject(int64_t rowIndex) const override;
|
|
96
|
+
|
|
97
|
+
private:
|
|
98
|
+
ArrowArrayView* m_array;
|
|
99
|
+
ArrowArrayView* m_epoch;
|
|
100
|
+
ArrowArrayView* m_fraction;
|
|
101
|
+
|
|
102
|
+
static Logger* logger;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
class TwoFieldTimeStampTZConverter : public TimeStampBaseConverter {
|
|
106
|
+
public:
|
|
107
|
+
explicit TwoFieldTimeStampTZConverter(ArrowArrayView* array, ArrowSchemaView* schema,
|
|
108
|
+
int32_t scale, PyObject* context);
|
|
109
|
+
|
|
110
|
+
PyObject* toPyObject(int64_t rowIndex) const override;
|
|
111
|
+
|
|
112
|
+
private:
|
|
113
|
+
ArrowArrayView* m_array;
|
|
114
|
+
ArrowArrayView* m_epoch;
|
|
115
|
+
ArrowArrayView* m_timezone;
|
|
116
|
+
|
|
117
|
+
static Logger* logger;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
class ThreeFieldTimeStampTZConverter : public TimeStampBaseConverter {
|
|
121
|
+
public:
|
|
122
|
+
explicit ThreeFieldTimeStampTZConverter(ArrowArrayView* array, ArrowSchemaView* schema,
|
|
123
|
+
int32_t scale, PyObject* context);
|
|
124
|
+
|
|
125
|
+
PyObject* toPyObject(int64_t rowIndex) const override;
|
|
126
|
+
|
|
127
|
+
private:
|
|
128
|
+
ArrowArrayView* m_array;
|
|
129
|
+
ArrowArrayView* m_epoch;
|
|
130
|
+
ArrowArrayView* m_fraction;
|
|
131
|
+
ArrowArrayView* m_timezone;
|
|
132
|
+
|
|
133
|
+
static Logger* logger;
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
} // namespace sf
|
|
137
|
+
|
|
138
|
+
#endif // PC_TIMESTAMPCONVERTER_HPP
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#ifndef PC_UTIL_MACROS_HPP
|
|
2
|
+
#define PC_UTIL_MACROS_HPP
|
|
3
|
+
|
|
4
|
+
/** the same macros as linux kernel's likely and unlikely. can help specific
|
|
5
|
+
* compiler to make branch prediction */
|
|
6
|
+
#if defined(__GNUC__)
|
|
7
|
+
#define LIKELY(x) (__builtin_expect(!!(x), 1))
|
|
8
|
+
#define UNLIKELY(x) (__builtin_expect(!!(x), 0))
|
|
9
|
+
#else
|
|
10
|
+
#define LIKELY(x) x
|
|
11
|
+
#define UNLIKELY(x) x
|
|
12
|
+
#endif // __GNUC__
|
|
13
|
+
|
|
14
|
+
#endif // PC_UTIL_MACROS_HPP
|