Skip to content

Commit

Permalink
Make expiration_time and app_metadata optional
Browse files Browse the repository at this point in the history
  • Loading branch information
EnricoMi committed Jul 26, 2024
1 parent 6d15c2f commit 11b5b3c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
6 changes: 3 additions & 3 deletions python/pyarrow/_flight.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,7 @@ cdef class FlightEndpoint(_Weakrefable):
cdef:
CFlightEndpoint endpoint

def __init__(self, ticket, locations, expiration_time, app_metadata):
def __init__(self, ticket, locations, expiration_time=None, app_metadata=""):
"""Create a FlightEndpoint from a ticket and list of locations.
Parameters
Expand All @@ -714,11 +714,11 @@ cdef class FlightEndpoint(_Weakrefable):
the ticket needed to access this flight
locations : list of string URIs
locations where this flight is available
expiration_time : TimestampScalar, optional
expiration_time : TimestampScalar optional, default None
Expiration time of this stream. If present, clients may assume
they can retry DoGet requests. Otherwise, clients should avoid
retrying DoGet requests.
app_metadata : bytes or str
app_metadata : bytes or str optional, default ""
Application-defined opaque metadata.
Raises
Expand Down
21 changes: 10 additions & 11 deletions python/pyarrow/tests/test_flight.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ def get_flight_info(self, context, descriptor):
pa.schema([('a', pa.int32())]),
descriptor,
[
flight.FlightEndpoint(b'', ['grpc://test'], None, b''),
flight.FlightEndpoint(b'', ['grpc://test']),
flight.FlightEndpoint(
b'',
[flight.Location.for_grpc_tcp('localhost', 5005)],
Expand Down Expand Up @@ -933,23 +933,22 @@ def test_eq():
flight.BasicAuth("user", "pass2")),
lambda: (flight.FlightDescriptor.for_command("foo"),
flight.FlightDescriptor.for_path("foo")),
lambda: (flight.FlightEndpoint(b"foo", [], None, b''),
flight.FlightEndpoint(b"bar", [], None, b'')),
lambda: (flight.FlightEndpoint(b"foo", []),
flight.FlightEndpoint(b"bar", [])),
lambda: (
flight.FlightEndpoint(
b"foo", [flight.Location("grpc+tcp://localhost:1234")], None, b''),
b"foo", [flight.Location("grpc+tcp://localhost:1234")]),
flight.FlightEndpoint(
b"foo", [flight.Location("grpc+tls://localhost:1234")], None, b'')
b"foo", [flight.Location("grpc+tls://localhost:1234")])
),
lambda: (
flight.FlightEndpoint(
b"foo", [], pa.scalar("2023-04-05T12:34:56").cast(pa.timestamp("s")),
b''),
b"foo", [], pa.scalar("2023-04-05T12:34:56").cast(pa.timestamp("s"))),
flight.FlightEndpoint(
b"foo", [],
pa.scalar("2023-04-05T12:34:56.789").cast(pa.timestamp("ms")), b'')),
lambda: (flight.FlightEndpoint(b"foo", [], None, b''),
flight.FlightEndpoint(b"foo", [], None, b'meta')),
pa.scalar("2023-04-05T12:34:56.789").cast(pa.timestamp("ms")))),
lambda: (flight.FlightEndpoint(b"foo", [], app_metadata=b''),
flight.FlightEndpoint(b"foo", [], app_metadata=b'meta')),
lambda: (
flight.FlightInfo(
pa.schema([]),
Expand Down Expand Up @@ -1760,7 +1759,7 @@ def test_roundtrip_types():
pa.schema([('a', pa.int32())]),
desc,
[
flight.FlightEndpoint(b'', ['grpc://test'], None, b''),
flight.FlightEndpoint(b'', ['grpc://test']),
flight.FlightEndpoint(
b'',
[flight.Location.for_grpc_tcp('localhost', 5005)],
Expand Down

0 comments on commit 11b5b3c

Please sign in to comment.