tvalentyn commented on code in PR #30556:
URL: https://github.com/apache/beam/pull/30556#discussion_r1526690762


##########
sdks/python/apache_beam/utils/proto_utils.py:
##########
@@ -36,6 +35,10 @@
 
 message_types = (message.Message, )
 
+_MICROS_TO_SECONDS = 1000000

Review Comment:
   ```suggestion
   _SECONDS_TO_MICROS = 10**6
   ```
   
   ditto elsewhere



##########
sdks/python/apache_beam/utils/proto_utils.py:
##########
@@ -123,8 +126,25 @@ def pack_Struct(**kwargs):
 def from_micros(cls, micros):
   # type: (Type[TimeMessageT], int) -> TimeMessageT
   result = cls()
-  result.FromMicroseconds(micros)
-  return result
+  if isinstance(result, duration_pb2.Duration):
+    result.FromMicroseconds(micros)
+    return result
+  elif isinstance(result, timestamp_pb2.Timestamp):
+    result.seconds = micros // _MICROS_TO_SECONDS

Review Comment:
   +1. add brief comment why we don't use   
timestamp_pb2.Timestamp.FromMicroseconds()
     and a reference an issue that has details.  



-- 
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: [email protected]

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

Reply via email to