lilixiang commented on a change in pull request #10893:
URL: https://github.com/apache/arrow/pull/10893#discussion_r685647708
##########
File path: python/pyarrow/tests/test_flight.py
##########
@@ -1545,6 +1573,33 @@ def test_roundtrip_errors():
with pytest.raises(flight.FlightInternalError, match=".*foo.*"):
list(client.list_flights())
+ data = [pa.array([-10, -5, 0, 5, 10])]
+ table = pa.Table.from_arrays(data, names=['a'])
+
+ exceptions = {
+ 'internal': flight.FlightInternalError,
+ 'timedout':flight.FlightTimedOutError,
+ 'cancel':flight.FlightCancelledError,
+ 'unauthenticated':flight.FlightUnauthenticatedError,
+ 'unauthorized':flight.FlightUnauthorizedError,
+ 'after_read_internal':flight.FlightInternalError,
+ 'after_read_timedout':flight.FlightTimedOutError,
+ 'after_read_cancel':flight.FlightCancelledError,
+ 'after_read_unauthenticated':flight.FlightUnauthenticatedError,
+ 'after_read_unauthorized':flight.FlightUnauthorizedError,
+
+ }
+
+ for command, exception in exceptions.items():
+
+ with pytest.raises(exception, match=".*foo.*"):
Review comment:
I see, I have fixed it. But a little problem about the define command,
after_read_xx and xx, should i remove after_read? I think if call write_table,
the error will raise before read_all, if just call close and don't use
after_read_xx cmd, the exception will raise before read. So just write
``` python
class ErrorFlightServer(FlightServerBase):
....
def do_put(self, context, descriptor, reader, writer):
if descriptor.command == b"internal":
raise flight.FlightInternalError("foo")
elif descriptor.command == b"timedout":
raise flight.FlightTimedOutError("foo")
elif descriptor.command == b"cancel":
raise flight.FlightCancelledError("foo")
elif descriptor.command == b"unauthenticated":
raise flight.FlightUnauthenticatedError("foo")
elif descriptor.command == b"unauthorized":
raise flight.FlightUnauthorizedError("foo")
elif descriptor.command == b"protobuf":
err_msg = b'this is an error message'
raise flight.FlightUnauthorizedError("foo", err_msg)
```
without `reader.read_all()` ? And don't care about the server read or not,
just raise error.
--
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]