You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2021/07/27 18:41:42 UTC

[GitHub] [arrow] pitrou commented on a change in pull request #10817: ARROW-9434: [C++] Store type code in UnionScalar

pitrou commented on a change in pull request #10817:
URL: https://github.com/apache/arrow/pull/10817#discussion_r677707357



##########
File path: cpp/src/arrow/scalar.cc
##########
@@ -310,6 +316,19 @@ struct MakeNullImpl {
     return Status::OK();
   }
 
+  Status Visit(const SparseUnionType& type) { return MakeUnionScalar(type); }
+
+  Status Visit(const DenseUnionType& type) { return MakeUnionScalar(type); }
+
+  template <typename T, typename ScalarType = typename TypeTraits<T>::ScalarType>
+  Status MakeUnionScalar(const T& type) {
+    if (type.num_fields() == 0) {
+      return Status::Invalid("Cannot make scalar of empty union type");
+    }
+    out_ = std::make_shared<ScalarType>(type.type_codes()[0], type_);

Review comment:
       It was already the case, this is basically adding the type code parameter.
   I agree this behaviour is debatable.




-- 
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.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org