pitrou commented on a change in pull request #9640: URL: https://github.com/apache/arrow/pull/9640#discussion_r589441820
########## File path: cpp/src/arrow/array/validate.cc ########## @@ -180,7 +180,9 @@ struct ValidateArrayImpl { bool IsBufferValid(int index) { return IsBufferValid(data, index); } static bool IsBufferValid(const ArrayData& data, int index) { - return data.buffers[index] != nullptr && data.buffers[index]->data() != nullptr; + return data.buffers[index] != nullptr && + (data.buffers[index]->is_cpu() ? data.buffers[index]->data() != nullptr + : true); Review comment: This is basically disabling the check on non-CPU buffers. Rather, you should use `data.buffers[index]->address()`. ########## File path: python/pyarrow/tests/test_cuda.py ########## @@ -744,6 +744,36 @@ def test_table_deserialize(): ).read_all()) +def test_create_table_with_device_buffers(): + # ARROW-11872: make sure that we can create an Arrow Table from + # GPU-located Arrays without crashing. + htable = make_table(10) + # Serialize the host table to bytes + sink = pa.BufferOutputStream() + with pa.ipc.new_stream(sink, htable.schema) as out: + out.write_table(htable) + hbuf = pa.py_buffer(sink.getvalue().to_pybytes()) + + # Copy the host bytes to a device buffer + dbuf = global_context.new_buffer(len(hbuf)) + dbuf.copy_from_host(hbuf, nbytes=len(hbuf)) + # Deserialize the device buffer into a Table + dtable = pa.ipc.open_stream(cuda.BufferReader(dbuf)).read_all() + # Construct a new Table from the device Table + dtable2 = pa.Table.from_arrays(dtable.columns, dtable.column_names) + + # Assert basic fields the same between host and device tables + assert htable.schema == dtable2.schema + assert htable.num_rows == dtable2.num_rows + assert htable.num_columns == dtable2.num_columns + # Assert byte-level equality + assert hbuf.equals(dbuf.copy_to_host()) + # Copy DtoH and assert the tables are still equivalent + assert htable.equals(pa.ipc.open_stream( + dbuf.copy_to_host() + ).read_all()) Review comment: This isn't much different from the test above, can you refactor the common bits? ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org