isapego commented on code in PR #4401:
URL: https://github.com/apache/ignite-3/pull/4401#discussion_r1762648234


##########
modules/platforms/python/cpp_module/type_conversion.h:
##########
@@ -122,40 +161,162 @@ static void submit_pyobject(ignite::binary_tuple_builder 
&builder, PyObject *obj
         return;
     }
 
-    if (PyBool_Check(obj)) {
-        bool val = (obj == Py_True);
+    if (PyObject_IsInstance(obj, py_get_module_timestamp_class())) {
+        auto double_value = PyFloat_AsDouble(obj);
+        if (PyErr_Occurred()) {
+            throw ignite::ignite_error("Can not get ticks count from a 
TIMESTAMP value");
+        }
+
+        auto secs = std::int64_t(std::trunc(double_value));
+        auto nanos = std::lround((double_value - secs) * 1'000'000'000);
+        ignite::ignite_timestamp value(secs, nanos);
         if (claim) {
-            ignite::protocol::claim_type_and_scale(builder, 
ignite::ignite_type::BOOLEAN);
-            builder.claim_bool(val);
+            ignite::protocol::claim_type_and_scale(builder, 
ignite::ignite_type::TIMESTAMP);
+            builder.claim_timestamp(value);
         } else {
-            ignite::protocol::append_type_and_scale(builder, 
ignite::ignite_type::BOOLEAN);
-            builder.append_bool(val);
+            ignite::protocol::append_type_and_scale(builder, 
ignite::ignite_type::TIMESTAMP);
+            builder.append_timestamp(value);
         }
         return;
     }
 
-    if (PyBytes_Check(obj)) {
-        auto *data = reinterpret_cast<std::byte*>(PyBytes_AsString(obj));
-        auto len = PyBytes_Size(obj);
-        ignite::bytes_view view(data, len);
+    if (PyObject_IsInstance(obj, py_get_module_number_class())) {
+        auto obj_str = PyObject_Str(obj);
+        if (!obj_str) {
+            throw ignite::ignite_error("Can not convert NUMBER to str");

Review Comment:
   Fixed. Filed a ticket to improve exception raising: 
https://issues.apache.org/jira/browse/IGNITE-23218



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@ignite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to