jorisvandenbossche commented on a change in pull request #7987:
URL: https://github.com/apache/arrow/pull/7987#discussion_r473910873



##########
File path: cpp/src/arrow/python/python_to_arrow.cc
##########
@@ -263,7 +264,12 @@ struct ValueConverter<TimestampType> {
           value = internal::PyDateTime_to_us(dt) - offset * 1000 * 1000;
           break;
         case TimeUnit::NANO:
-          value = internal::PyDateTime_to_ns(dt) - offset * 1000 * 1000 * 1000;
+          // Conversion to nanoseconds can overflow -> check multiply of 
microseconds
+          value = internal::PyDateTime_to_us(dt);
+          if (arrow::internal::MultiplyWithOverflow(value, 1000, &value)) {
+            return internal::InvalidValue(obj, "out of bounds for nanosecond 
resolution");
+          }
+          value -= offset * 1000 * 1000 * 1000;

Review comment:
       The offset is always a small number (time zone offsets are always less 
then 12 hours ?), so shouldn't give any problem?




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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to