Skip to content

Commit

Permalink
Use None as default for total_records and total_bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
EnricoMi committed Aug 30, 2024
1 parent 4524c96 commit 988fef6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
10 changes: 5 additions & 5 deletions python/pyarrow/_flight.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,7 @@ cdef class FlightInfo(_Weakrefable):
return obj

def __init__(self, Schema schema, FlightDescriptor descriptor, endpoints,
total_records=-1, total_bytes=-1, ordered=False, app_metadata=""):
total_records=None, total_bytes=None, ordered=False, app_metadata=""):
"""Create a FlightInfo object from a schema, descriptor, and endpoints.
Parameters
Expand All @@ -896,10 +896,10 @@ cdef class FlightInfo(_Weakrefable):
the descriptor for this flight.
endpoints : list of FlightEndpoint
a list of endpoints where this flight is available.
total_records : int optional, default -1
the total records in this flight, or -1 if unknown.
total_bytes : int optional, default -1
the total bytes in this flight, or -1 if unknown.
total_records : int optional, default None
the total records in this flight, -1 or None if unknown.
total_bytes : int optional, default None
the total bytes in this flight, -1 or None if unknown.
ordered : boolean optional, default False
Whether endpoints are in the same order as the data.
app_metadata : bytes or str optional, default ""
Expand Down
18 changes: 18 additions & 0 deletions python/pyarrow/tests/test_flight.py
Original file line number Diff line number Diff line change
Expand Up @@ -1020,6 +1020,24 @@ def test_eq():
assert lhs1 != rhs1


def test_flight_info_defaults():
fi1 = flight.FlightInfo(pa.schema([]), flight.FlightDescriptor.for_path(), [])
fi2 = flight.FlightInfo(
pa.schema([]),
flight.FlightDescriptor.for_path(), [], total_records=-1, total_bytes=-1)
fi3 = flight.FlightInfo(
pa.schema([]),
flight.FlightDescriptor.for_path(), [], total_records=None, total_bytes=None)

assert fi1.total_records == -1
assert fi2.total_records == -1
assert fi3.total_records == -1

assert fi1.total_bytes == -1
assert fi2.total_bytes == -1
assert fi3.total_bytes == -1


def test_flight_server_location_argument():
locations = [
None,
Expand Down

0 comments on commit 988fef6

Please sign in to comment.