Skip to content

Commit ec5ccb4

Browse files
committed
MORE WIP
1 parent fec6998 commit ec5ccb4

File tree

1 file changed

+16
-4
lines changed
  • bindings/python/pymongoarrow

1 file changed

+16
-4
lines changed

bindings/python/pymongoarrow/lib.pyx

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ from math import isnan
2626
# Python imports
2727
import bson
2828
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
3030
from pyarrow.lib import (
3131
tobytes, StructType, int32, int64, float64, string, bool_, list_
3232
)
@@ -487,7 +487,7 @@ cdef class ObjectIdBuilder(_ArrayBuilderBase):
487487
self.builder.get().Finish(&out)
488488
result = pyarrow_wrap_array(out)
489489
for x in result:
490-
print("CORRECT: ", x)
490+
print("CORRECT: ", result.type, type(result), x.type, type(x))
491491
return pyarrow_wrap_array(out).cast(ObjectIdType())
492492

493493
cdef shared_ptr[CFixedSizeBinaryBuilder] unwrap(self):
@@ -787,10 +787,22 @@ cdef class DocumentBuilder(_ArrayBuilderBase):
787787
wrapped = pyarrow_wrap_array(out)
788788
python_out = []
789789
for original in wrapped:
790+
new_types = []
791+
new_names = list(original.keys())
790792
for fname, ftype in original.items():
793+
#new_names.append(fname)
791794
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]))
794806
return wrapped
795807

796808
cdef shared_ptr[CStructBuilder] unwrap(self):

0 commit comments

Comments
 (0)