lidavidm commented on a change in pull request #10893:
URL: https://github.com/apache/arrow/pull/10893#discussion_r685172981
##########
File path: python/pyarrow/_flight.pyx
##########
@@ -949,7 +949,43 @@ cdef class MetadataRecordBatchWriter(_CRecordBatchWriter):
# individual batches to have control.
with nogil:
check_flight_status(
- self.writer.get().WriteRecordBatch(deref(batch.batch)))
+ self._writer().WriteRecordBatch(deref(batch.batch)))
+
+ def write_table(self, Table table, max_chunksize=None, **kwargs):
+ """
+ Write Table to stream in (contiguous) RecordBatch objects.
+
+ Parameters
+ ----------
+ table : Table
+ max_chunksize : int, default None
+ Maximum size for RecordBatch chunks. Individual chunks may be
+ smaller depending on the chunk layout of individual columns.
+ """
+ cdef:
+ # max_chunksize must be > 0 to have any impact
+ int64_t c_max_chunksize = -1
+
+ if 'chunksize' in kwargs:
+ max_chunksize = kwargs['chunksize']
+ msg = ('The parameter chunksize is deprecated for the write_table '
+ 'methods as of 0.15, please use parameter '
+ 'max_chunksize instead')
+ warnings.warn(msg, FutureWarning)
+
+ if max_chunksize is not None:
+ c_max_chunksize = max_chunksize
+
+ with nogil:
+ check_flight_status(
+ self._writer().WriteTable(table.table[0], c_max_chunksize))
Review comment:
This is consistent with what's in ipc.pxi so it's OK.
##########
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 suggested also testing just `writer.close()` in a separate block by
itself to ensure the error propagates even if you don't write data - does that
also work?
--
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]