Repository navigation
fix: avoid timestamp rounding across precision boundaries - #724
Draft
Kayvan-Zahiri wants to merge 1 commit into
Draft
Kayvan-Zahiri wants to merge 1 commit into
Kayvan-Zahiri wants to merge 1 commit into
Conversation
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #724 +/- ##
==========================================
- Coverage 90.49% 90.47% -0.03%
==========================================
Files 40 40
Lines 3568 3570 +2
==========================================
+ Hits 3229 3230 +1
- Misses 339 340 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed Changes
Avoid floating-point division when reducing datetime/timedelta nanoseconds to microseconds, milliseconds, or seconds in Point line protocol. Near an interval boundary, float rounding can move the timestamp into the next interval before the final integer conversion.
For example, with the documented PandasDateTimeHelper, a timestamp of 1700000000000000999 ns is serialized at microsecond precision as 1700000000000001, although truncation gives 1700000000000000.
Use exact integer arithmetic, preserving the existing truncation-toward-zero behavior for negative timestamps. Nanosecond precision and integer timestamp inputs retain their existing paths.
Validation
Point.time(...).to_line_protocol()tests cover positive and negative pandas timestamps just before and exactly on microsecond/millisecond/second boundaries, plus unchanged nanosecond precision.test_point.py,test_DateHelper.py, andtest_PandasDateTimeHelper.py.git diff --checkpass.flake8 setup.py influxdb_client/reports two existing E721 diagnostics in_async/api_client.py:270and_sync/api_client.py:287. Unchangedpoint.pyproduces byte-for-byte identical output. No diagnostics are suppressed.Checklist
pytest testsintegration suite (requires InfluxDB)AI assistance: OpenAI Codex assisted with reproduction, patch, tests, and this description.