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


##########
modules/platforms/python/cpp_module/type_conversion.h:
##########
@@ -85,23 +88,59 @@ static PyObject* primitive_to_pyobject(ignite::primitive 
value) {
         }
 
         case ignite_type::BYTE_ARRAY: {
-            auto &blob_val =  value.get<std::vector<std::byte>>();
+            auto &blob_val = value.get<std::vector<std::byte>>();
             return PyBytes_FromStringAndSize((const char*)blob_val.data(), 
blob_val.size());
         }
 
-        case ignite_type::UUID:
-        case ignite_type::DATE:
-        case ignite_type::TIMESTAMP:
-        case ignite_type::TIME:
-        case ignite_type::DATETIME:
-        case ignite_type::BITMASK:
-        case ignite_type::DECIMAL:
-        case ignite_type::PERIOD:
-        case ignite_type::DURATION:
-        case ignite_type::NUMBER:
+        case ignite_type::UUID: {
+            auto &uuid_val = value.get<ignite::uuid>();
+            std::byte buf[16];
+            ignite::detail::bytes::store<ignite::detail::endian::BIG>(buf, 
uuid_val.get_most_significant_bits());
+            ignite::detail::bytes::store<ignite::detail::endian::BIG>(buf + 8, 
uuid_val.get_least_significant_bits());
+            return py_create_uuid({buf, sizeof(buf)});
+        }
+
+        case ignite_type::DATE: {
+            auto &date_val = value.get<ignite::ignite_date>();
+            return py_create_date(date_val);
+        }
+
+        case ignite_type::TIME: {
+            auto &time_val = value.get<ignite::ignite_time>();
+            return py_create_time(time_val);
+        }
+
+        case ignite_type::DATETIME: {
+            auto &datetime_val = value.get<ignite::ignite_date_time>();
+            return py_create_datetime(datetime_val);
+        }
+
+        case ignite_type::TIMESTAMP: {
+            auto &timestamp_val = value.get<ignite::ignite_timestamp>();
+            auto double_val = timestamp_val.get_epoch_second() + 
timestamp_val.get_nano() * 1.0E-9;
+            return PyFloat_FromDouble(double_val);
+        }
+
+        case ignite_type::DECIMAL: {
+            auto &decimal_val = value.get<ignite::big_decimal>();
+            std::stringstream converter;
+            converter << decimal_val;
+            auto str = converter.str();
+            return py_create_number(str);
+        }
+
+        case ignite_type::DURATION: {
+            auto &duration_val = value.get<ignite::ignite_duration>();
+            return py_create_timedelta(duration_val);
+        }
+
+        case ignite_type::PERIOD:{
+            PyErr_SetString(PyExc_RuntimeError, "PERIOD data type is not 
supported");

Review Comment:
   https://issues.apache.org/jira/browse/IGNITE-23217



-- 
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