lidavidm commented on a change in pull request #10817:
URL: https://github.com/apache/arrow/pull/10817#discussion_r677703724
##########
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:
I see there's the XXX comment below...
##########
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:
This will be a scalar with is_valid = false, right? Shouldn't this
instead be a valid scalar containing a null scalar of one of the children?
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]