anishmehta24 opened a new pull request, #41558:
URL: https://github.com/apache/beam/pull/41558

   Fixes #41557
   
   `Duration.to_proto()` split the microseconds like `Timestamp.to_proto()` 
does, rounding the seconds down and keeping `nanos` non-negative. A 
`google.protobuf.Duration` instead needs `nanos` with the same sign as 
`seconds`, so negative durations with a fractional part came out invalid 
(`-1.5s` was `seconds: -2, nanos: 500000000`, and `ToJsonString()` raised "Sign 
mismatch"). It now uses `Duration.FromMicroseconds`, as 
`proto_utils.from_micros` already does. Positive durations give the same proto 
as before.
   
   Added `test_to_proto_negative`: for -1us, -1.5s, -1234.000056s and -2s it 
checks the proto fields, that `ToJsonString()` accepts the proto, and that 
`from_proto` gives the same `Duration` back. It fails on master, and 
`apache_beam/utils/timestamp_test.py` passes.
   


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