pitrou commented on a change in pull request #9560:
URL: https://github.com/apache/arrow/pull/9560#discussion_r582008525
##########
File path: python/pyarrow/types.pxi
##########
@@ -2386,25 +2426,102 @@ def struct(fields):
return pyarrow_wrap_data_type(struct_type)
+cdef _extract_union_params(children_fields, type_codes,
+ vector[shared_ptr[CField]]* c_fields,
+ vector[int8_t]* c_type_codes):
+ cdef:
+ Field child_field
+
+ for child_field in children_fields:
+ c_fields[0].push_back(child_field.sp_field)
+
+ if type_codes is not None:
+ if len(type_codes) != <Py_ssize_t>(c_fields.size()):
+ raise ValueError("type_codes should have the same length "
+ "as fields")
+ for code in type_codes:
+ c_type_codes[0].push_back(code)
+ else:
+ c_type_codes[0] = range(c_fields.size())
+
+
+def sparse_union(children_fields, type_codes=None):
+ """
+ Create SparseUnionType from children fields.
+
+ A union is defined by an ordered sequence of child types; each slot in
+ the union can have a value chosen from these types.
+
+ Parameters
+ ----------
+ fields : sequence of Field values
Review comment:
What is better? `children_fields` or `child_fields`?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]