@@ -118,19 +118,31 @@ def _from_32_64_arrow(
118118 if isinstance (data , pa .ChunkedArray ):
119119 data = data .combine_chunks ()
120120 mask_buf , data_buf = data .buffers ()
121- rmm_data_buffer = rmm .DeviceBuffer .to_device (
122- np .frombuffer (data_buf )
123- .view (view_type )[::step ]
124- .copy ()
125- .view ("uint8" )
126- )
127- plc_column = plc .Column .from_rmm_buffer (
128- rmm_data_buffer ,
129- plc .DataType (plc_type , - data .type .scale ),
130- len (data ),
131- [],
132- )
133- if mask_buf is not None :
121+ if data_buf is None :
122+ # If data_buf is None, create an empty column
123+ plc_column = plc .Column (
124+ data_type = plc .DataType (plc_type , - data .type .scale ),
125+ size = 0 ,
126+ data = None ,
127+ mask = None ,
128+ null_count = 0 ,
129+ offset = 0 ,
130+ children = [],
131+ )
132+ else :
133+ rmm_data_buffer = rmm .DeviceBuffer .to_device (
134+ np .frombuffer (data_buf )
135+ .view (view_type )[::step ]
136+ .copy ()
137+ .view ("uint8" )
138+ )
139+ plc_column = plc .Column .from_rmm_buffer (
140+ rmm_data_buffer ,
141+ plc .DataType (plc_type , - data .type .scale ),
142+ len (data ),
143+ [],
144+ )
145+ if mask_buf is not None and data_buf is not None :
134146 mask_size = plc .null_mask .bitmask_allocation_size_bytes (len (data ))
135147 if mask_buf .size < mask_size :
136148 rmm_mask_buffer = rmm .DeviceBuffer (size = mask_size )
@@ -391,7 +403,9 @@ def from_arrow(cls, data: pa.Array | pa.ChunkedArray) -> Self:
391403
392404 def to_arrow (self ) -> pa .Array :
393405 data_buf_32 = np .array (self .base_data .memoryview ()).view ("int32" ) # type: ignore[union-attr]
394- data_buf_128 = np .empty (len (data_buf_32 ) * 4 , dtype = "int32" )
406+ data_buf_128 : np .ndarray = np .empty (
407+ len (data_buf_32 ) * 4 , dtype = "int32"
408+ )
395409
396410 # use striding to set the first 32 bits of each 128-bit chunk:
397411 data_buf_128 [::4 ] = data_buf_32
@@ -464,8 +478,9 @@ def from_arrow(cls, data: pa.Array | pa.ChunkedArray) -> Self:
464478 return result
465479
466480 def to_arrow (self ) -> pa .Array :
481+ dtype : Decimal128Dtype
467482 if isinstance (self .dtype , pd .ArrowDtype ):
468- dtype = pyarrow_dtype_to_cudf_dtype (self .dtype )
483+ dtype = pyarrow_dtype_to_cudf_dtype (self .dtype ) # type: ignore[assignment]
469484 else :
470485 dtype = self .dtype
471486
@@ -510,7 +525,9 @@ def from_arrow(cls, data: pa.Array | pa.ChunkedArray) -> Self:
510525
511526 def to_arrow (self ) -> pa .Array :
512527 data_buf_64 = np .array (self .base_data .memoryview ()).view ("int64" ) # type: ignore[union-attr]
513- data_buf_128 = np .empty (len (data_buf_64 ) * 2 , dtype = "int64" )
528+ data_buf_128 : np .ndarray = np .empty (
529+ len (data_buf_64 ) * 2 , dtype = "int64"
530+ )
514531
515532 # use striding to set the first 64 bits of each 128-bit chunk:
516533 data_buf_128 [::2 ] = data_buf_64
0 commit comments