[
https://issues.apache.org/jira/browse/ARROW-972?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16244673#comment-16244673
]
ASF GitHub Bot commented on ARROW-972:
--------------------------------------
pcmoritz commented on a change in pull request #1216: ARROW-972: UnionArray in
pyarrow
URL: https://github.com/apache/arrow/pull/1216#discussion_r149786978
##########
File path: cpp/src/arrow/array.cc
##########
@@ -393,6 +393,71 @@ UnionArray::UnionArray(const std::shared_ptr<DataType>&
type, int64_t length,
SetData(internal_data);
}
+std::shared_ptr<DataType> MakeUnionArrayType(
+ UnionMode mode, const std::vector<std::shared_ptr<Array>>& children) {
+ auto types = std::vector<std::shared_ptr<Field>>();
+ std::vector<uint8_t> type_codes;
+ uint8_t counter = 0;
+ for (const auto& child : children) {
+ types.push_back(field(std::to_string(counter), child->type()));
+ type_codes.push_back(counter);
+ counter++;
+ }
+ return union_(types, type_codes, mode);
+}
+
+Status UnionArray::FromDense(const Array& type_ids, const Array& value_offsets,
+ const std::vector<std::shared_ptr<Array>>&
children,
+ std::shared_ptr<Array>* out) {
+ if (value_offsets.length() == 0) {
+ return Status::Invalid("UnionArray offsets must have non-zero length");
+ }
+
+ if (value_offsets.type_id() != Type::INT32) {
+ return Status::Invalid("UnionArray offsets must be signed int32");
+ }
+
+ if (type_ids.type_id() != Type::INT8) {
+ return Status::Invalid("UnionArray type_ids must be signed int8");
+ }
+
+ BufferVector buffers = {type_ids.null_bitmap(),
+ static_cast<const UInt8Array&>(type_ids).values(),
+ static_cast<const
Int32Array&>(value_offsets).values()};
Review comment:
done
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> [Python] Add test cases and basic APIs for UnionArray
> -----------------------------------------------------
>
> Key: ARROW-972
> URL: https://issues.apache.org/jira/browse/ARROW-972
> Project: Apache Arrow
> Issue Type: New Feature
> Components: Python
> Affects Versions: 0.3.0
> Reporter: Wes McKinney
> Assignee: Philipp Moritz
> Labels: pull-request-available
> Fix For: 0.8.0
>
>
> While this is implemented in C++, there isn't any API exposure yet in Python
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)