Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bindings/python/pymongoarrow/lib.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,12 @@ cdef class BuilderManager:
raise ValueError("Could not append raw value to", full_key.decode('utf8'))

# Recurse into documents.
if value_t == BSON_TYPE_DOCUMENT:
if value_t == BSON_TYPE_DOCUMENT and builder.type_marker == BSON_TYPE_DOCUMENT:
bson_iter_recurse(doc_iter, &child_iter)
self.parse_document(&child_iter, full_key, BSON_TYPE_DOCUMENT)

# Recurse into arrays.
if value_t == BSON_TYPE_ARRAY:
if value_t == BSON_TYPE_ARRAY and builder.type_marker == BSON_TYPE_ARRAY:
bson_iter_recurse(doc_iter, &child_iter)
self.parse_document(&child_iter, full_key, BSON_TYPE_ARRAY)

Expand Down
6 changes: 6 additions & 0 deletions bindings/python/test/test_arrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,12 @@ def test_schema_missing_field(self):
out = func(self.coll, {} if func == find_arrow_all else [], schema=schema).drop(["_id"])
self.assertEqual(out["list_field"].to_pylist(), expected)

def test_schema_incorrect_data_type(self):
self.coll.delete_many({})
self.coll.insert_one({"x": {"y": 1}})
out = find_arrow_all(self.coll, {}, schema=Schema({"x": str}))
assert out.to_pylist() == [{"x": None}]

def test_auto_schema_nested(self):
# Create table with random data of various types.
_, data = self._create_nested_data()
Expand Down
Loading