What happened?
Duration(seconds) truncates instead of rounding when seconds is a float, so it can land one microsecond below the value passed in. This is the same thing #40235 described for Timestamp, which #40257 fixed, but Duration.__init__ still does:
self.micros = int(seconds * 1000000) + int(micros)
>>> from apache_beam.utils.timestamp import Duration
>>> Duration(2.000002).micros
2000001 # expected 2000002
>>> Duration(-2.000002).micros
-2000001 # expected -2000002
Using round() like the Timestamp constructor now does fixes it.
Issue Priority
Priority: 3 (minor)
Issue Components
What happened?
Duration(seconds)truncates instead of rounding whensecondsis a float, so it can land one microsecond below the value passed in. This is the same thing #40235 described forTimestamp, which #40257 fixed, butDuration.__init__still does:Using
round()like theTimestampconstructor now does fixes it.Issue Priority
Priority: 3 (minor)
Issue Components