@@ -26,7 +26,7 @@ from math import isnan
26
26
# Python imports
27
27
import bson
28
28
import numpy as np
29
- from pyarrow import timestamp, struct , field, scalar, FixedSizeBinaryScalar, StructScalar
29
+ from pyarrow import timestamp, struct , field, scalar, FixedSizeBinaryScalar, StructScalar, array
30
30
from pyarrow.lib import (
31
31
tobytes, StructType, int32, int64, float64, string, bool_, list_
32
32
)
@@ -487,7 +487,7 @@ cdef class ObjectIdBuilder(_ArrayBuilderBase):
487
487
self .builder.get().Finish(& out)
488
488
result = pyarrow_wrap_array(out)
489
489
for x in result:
490
- print (" CORRECT: " , x )
490
+ print (" CORRECT: " , result.type, type (result), x.type, type (x) )
491
491
return pyarrow_wrap_array(out).cast(ObjectIdType())
492
492
493
493
cdef shared_ptr[CFixedSizeBinaryBuilder] unwrap(self ):
@@ -787,10 +787,22 @@ cdef class DocumentBuilder(_ArrayBuilderBase):
787
787
wrapped = pyarrow_wrap_array(out)
788
788
python_out = []
789
789
for original in wrapped:
790
+ new_types = []
791
+ new_names = list (original.keys())
790
792
for fname, ftype in original.items():
793
+ # new_names.append(fname)
791
794
if isinstance (ftype, FixedSizeBinaryScalar) and ftype.type.byte_width == 12 : # ObjectIdType
792
- print (" BEFORE: " , fname, ftype)
793
- print (" AFTER: " , fname, ftype.cast(ObjectIdType()))
795
+ print (" TYPE: " , ftype, ftype.type, type (ftype))
796
+ new_ftype = ObjectIdType()
797
+ # print("TYPE: ", new_ftype, new_ftype.storage_type, type(new_ftype))
798
+ # print("ARRAY: ", array([(fname, ftype)]))
799
+ new_types.append(new_ftype)
800
+ else :
801
+ new_types.append(ftype.type)
802
+ python_out.append(struct (zip (new_names, new_types)))
803
+ print (" BEFORE: " , wrapped, wrapped.type, type (wrapped))
804
+ print (" AFTER: " , python_out[0 ], python_out, type (python_out[0 ]))
805
+ print (" AFTER AFTER: " , array([], type = python_out[0 ]))
794
806
return wrapped
795
807
796
808
cdef shared_ptr[CStructBuilder] unwrap(self ):
0 commit comments