EnricoMi commented on code in PR #43537:
URL: https://github.com/apache/arrow/pull/43537#discussion_r1701878072
##########
python/pyarrow/_flight.pyx:
##########
@@ -770,7 +801,9 @@ cdef class FlightEndpoint(_Weakrefable):
def __repr__(self):
return (f"<pyarrow.flight.FlightEndpoint ticket={self.ticket!r} "
- f"locations={self.locations!r}>")
+ f"locations={self.locations!r} "
+ f"expiration_time={self.expiration_time} "
+ f"app_metadata='{self.app_metadata.hex()}'>")
Review Comment:
This matches the C++ implementation of `ToString`. In Python, we could
easily use `self.app_metadata`, which represents the metadata bytes in ASCII
with automatic escaping of non-printable characters, e.g. `b'abc\xe2\x80\xa6'`,
which is more readable in the absence of non-printable characters than `.hex()`.
##########
python/pyarrow/_flight.pyx:
##########
@@ -950,7 +1005,9 @@ cdef class FlightInfo(_Weakrefable):
f"descriptor={self.descriptor} "
f"endpoints={self.endpoints} "
f"total_records={self.total_records} "
- f"total_bytes={self.total_bytes}>")
+ f"total_bytes={self.total_bytes} "
+ f"ordered={'true' if self.ordered else 'false'} "
Review Comment:
This matches the C++ implementation of `ToString`. In Python, you would
expect `True` or `False` though. Happy to change this to
```suggestion
f"ordered={self.ordered} "
```
##########
python/pyarrow/tests/test_flight.py:
##########
@@ -877,14 +879,18 @@ def test_repr():
descriptor_repr = "<pyarrow.flight.FlightDescriptor cmd=b'foo'>"
endpoint_repr = ("<pyarrow.flight.FlightEndpoint "
"ticket=<pyarrow.flight.Ticket ticket=b'foo'> "
- "locations=[]>")
+ "locations=[] "
+ "expiration_time=2023-04-05 12:34:56+00:00 "
+
"app_metadata='656e64706f696e7420617070206d65746164617461'>")
info_repr = (
"<pyarrow.flight.FlightInfo "
"schema= "
"descriptor=<pyarrow.flight.FlightDescriptor path=[]> "
"endpoints=[] "
- "total_records=-1 "
- "total_bytes=-1>")
+ "total_records=1 "
+ "total_bytes=42 "
+ "ordered=true "
Review Comment:
In Python, you would expect
ordered=True
here.
##########
python/pyarrow/tests/test_flight.py:
##########
@@ -877,14 +879,18 @@ def test_repr():
descriptor_repr = "<pyarrow.flight.FlightDescriptor cmd=b'foo'>"
endpoint_repr = ("<pyarrow.flight.FlightEndpoint "
"ticket=<pyarrow.flight.Ticket ticket=b'foo'> "
- "locations=[]>")
+ "locations=[] "
+ "expiration_time=2023-04-05 12:34:56+00:00 "
+
"app_metadata='656e64706f696e7420617070206d65746164617461'>")
Review Comment:
This could read (which is more readable)
app_metadata=b'endpoint app metadata'
if we wouldn't stick to the C++ implementation of `ToString` here.
##########
python/pyarrow/_flight.pyx:
##########
@@ -855,10 +888,14 @@ 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
- the total records in this flight, or -1 if unknown
- total_bytes : int
- the total bytes in this flight, or -1 if unknown
+ total_records : int optional, default None
+ the total records in this flight, or -1 if unknown.
+ total_bytes : int optional, default None
+ the total bytes in this flight, or -1 if unknown.
Review Comment:
While adding new attributes `ordered` and `app_metadata` as optional
arguments, which simplifies user and test code, making existing `total_records`
and `total_bytes` optional sounds like a good idea
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]