Skip to content

Commit

Permalink
apacheGH-43727: [Python] RecordBatch failse gracefully on non-cpu dev…
Browse files Browse the repository at this point in the history
…ices
  • Loading branch information
danepitkin committed Aug 16, 2024
1 parent d801dae commit 561239e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions python/pyarrow/lib.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,7 @@ cdef class Table(_Tabular):
CTable* table

cdef void init(self, const shared_ptr[CTable]& table)
cdef void _assert_cpu(self) noexcept


cdef class RecordBatch(_Tabular):
Expand All @@ -528,6 +529,7 @@ cdef class RecordBatch(_Tabular):
Schema _schema

cdef void init(self, const shared_ptr[CRecordBatch]& table)
cdef void _assert_cpu(self) except *


cdef class Device(_Weakrefable):
Expand Down
7 changes: 7 additions & 0 deletions python/pyarrow/table.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -3905,6 +3905,10 @@ cdef class RecordBatch(_Tabular):
"""
return self.device_type == DeviceAllocationType.CPU

cdef void _assert_cpu(self) except *:
if self.sp_batch.get().device_type() != CDeviceAllocationType_kCPU:
raise NotImplementedError("Implemented only for data on CPU device")


def _reconstruct_record_batch(columns, schema):
"""
Expand Down Expand Up @@ -5679,6 +5683,9 @@ cdef class Table(_Tabular):
"""
return self.to_reader().__arrow_c_stream__(requested_schema)

cdef void _assert_cpu(self) noexcept:
return # TODO GH-43728


def _reconstruct_table(arrays, schema):
"""
Expand Down

0 comments on commit 561239e

Please sign in to comment.