Skip to content

Commit

Permalink
Fix Flight Timestamp definition to OS-agnostic nanoseconds
Browse files Browse the repository at this point in the history
  • Loading branch information
EnricoMi committed Sep 10, 2024
1 parent 43762da commit 84bbe5f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
3 changes: 2 additions & 1 deletion cpp/src/arrow/flight/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ class FlightServerBase;
/// > all minutes are 60 seconds long, i.e. leap seconds are "smeared"
/// > so that no leap second table is needed for interpretation. Range
/// > is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z.
using Timestamp = std::chrono::system_clock::time_point;
using Timestamp =
std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds>;

/// \brief A Flight-specific status code. Used to encode some
/// additional status codes into an Arrow Status.
Expand Down
16 changes: 3 additions & 13 deletions python/pyarrow/tests/test_flight.py
Original file line number Diff line number Diff line change
Expand Up @@ -1167,19 +1167,9 @@ def test_flight_get_info():
assert info.endpoints[0].expiration_time is None
assert info.endpoints[0].app_metadata == b""
assert info.endpoints[0].locations[0] == flight.Location('grpc://test')
# on macOS, system_clock::duration is milliseconds
# on Windows, system_clock::duration is 100 nanoseconds
# on Linux, system_clock::duration is nanoseconds
ts = None
if pa._platform.system() == 'Darwin':
ts = "2023-04-05T12:34:56.789012000+00:00"
elif pa._platform.system() == 'Windows':
ts = "2023-04-05T12:34:56.789012300+00:00"
elif pa._platform.system() == 'Linux':
ts = "2023-04-05T12:34:56.789012345+00:00"
if ts is not None:
assert info.endpoints[1].expiration_time == \
pa.scalar(ts).cast(pa.timestamp("ns", "UTC"))
assert info.endpoints[1].expiration_time == \
pa.scalar("2023-04-05T12:34:56.789012345+00:00") \
.cast(pa.timestamp("ns", "UTC"))
assert info.endpoints[1].app_metadata == b"endpoint app metadata"
assert info.endpoints[1].locations[0] == \
flight.Location.for_grpc_tcp('localhost', 5005)
Expand Down

0 comments on commit 84bbe5f

Please sign in to comment.