Skip to content

Commit

Permalink
Test FlightEndpoint with nanoseconds
Browse files Browse the repository at this point in the history
  • Loading branch information
EnricoMi committed Aug 6, 2024
1 parent 501d3a6 commit e5ece4b
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions python/pyarrow/tests/test_flight.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ def get_flight_info(self, context, descriptor):
flight.FlightEndpoint(
b'',
[flight.Location.for_grpc_tcp('localhost', 5005)],
pa.scalar("2023-04-05T12:34:56.789").cast(pa.timestamp("ms")),
pa.scalar("2023-04-05T12:34:56.789012345").cast(pa.timestamp("ns")),
"endpoint app metadata"
),
],
Expand Down Expand Up @@ -1150,8 +1150,19 @@ 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')
assert info.endpoints[1].expiration_time == \
pa.scalar("2023-04-05T12:34:56.789+00:00").cast(pa.timestamp("ns", "UTC"))
# 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].app_metadata == b"endpoint app metadata"
assert info.endpoints[1].locations[0] == \
flight.Location.for_grpc_tcp('localhost', 5005)
Expand Down Expand Up @@ -1763,7 +1774,7 @@ def test_roundtrip_types():
flight.FlightEndpoint(
b'',
[flight.Location.for_grpc_tcp('localhost', 5005)],
pa.scalar("2023-04-05T12:34:56.789012").cast(pa.timestamp("us")),
pa.scalar("2023-04-05T12:34:56.789012345").cast(pa.timestamp("ns")),
b'endpoint app metadata'
),
],
Expand Down

0 comments on commit e5ece4b

Please sign in to comment.