ump45nose commented on code in PR #55310:
URL: https://github.com/apache/arrow/pull/55310#discussion_r4480832543
##########
python/pyarrow/tests/test_flight.py:
##########
@@ -2059,6 +2060,67 @@ def test_roundtrip_types():
assert endpoint == flight.FlightEndpoint.deserialize(endpoint.serialize())
+def test_pickle_flight_types():
+ """Flight value types should round-trip through pickle (GH-35150)."""
+ action = flight.Action("action1", b"action1-body")
+ assert action == pickle.loads(pickle.dumps(action))
+
+ ticket = flight.Ticket("foo")
+ assert ticket == pickle.loads(pickle.dumps(ticket))
+
+ result = flight.Result(b"result1")
+ assert result == pickle.loads(pickle.dumps(result))
+
+ basic_auth = flight.BasicAuth("username1", "password1")
+ assert basic_auth == pickle.loads(pickle.dumps(basic_auth))
+
+ schema_result = flight.SchemaResult(pa.schema([('a', pa.int32())]))
+ assert schema_result == pickle.loads(pickle.dumps(schema_result))
+
+ desc = flight.FlightDescriptor.for_command("test")
+ assert desc == pickle.loads(pickle.dumps(desc))
+
+ desc = flight.FlightDescriptor.for_path("a", "b", "test.arrow")
+ assert desc == pickle.loads(pickle.dumps(desc))
+
+ location = flight.Location.for_grpc_tcp('localhost', 5005)
+ assert location == pickle.loads(pickle.dumps(location))
+
+ endpoint = flight.FlightEndpoint(
+ ticket,
+ ['grpc://test', location],
+ pa.scalar("2023-04-05T12:34:56").cast(pa.timestamp("s")),
+ b'endpoint app metadata'
+ )
+ assert endpoint == pickle.loads(pickle.dumps(endpoint))
+
+ info = flight.FlightInfo(
+ pa.schema([('a', pa.int32())]),
+ desc,
+ [
+ flight.FlightEndpoint(b'', ['grpc://test']),
+ flight.FlightEndpoint(
+ b'',
+ [location],
+
pa.scalar("2023-04-05T12:34:56.789012345").cast(pa.timestamp("ns")),
+ b'endpoint app metadata'
+ ),
+ ],
+ 1,
+ 42,
+ True,
+ b'test app metadata'
+ )
+ info2 = pickle.loads(pickle.dumps(info))
+ assert info.schema == info2.schema
+ assert info.descriptor == info2.descriptor
+ assert info.total_bytes == info2.total_bytes
+ assert info.total_records == info2.total_records
+ assert info.ordered == info2.ordered
+ assert info.app_metadata == info2.app_metadata
+ assert info.endpoints == info2.endpoints
Review Comment:
No good reason: I had mirrored the existing serialize/deserialize round-trip
test above, but `FlightInfo.__eq__` compares the underlying C++ objects, so a
direct comparison works. Simplified in 99a7880. (AI-assisted reply.)
--
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]