lidavidm commented on a change in pull request #11022:
URL: https://github.com/apache/arrow/pull/11022#discussion_r703002257



##########
File path: cpp/src/arrow/array/builder_dict.h
##########
@@ -282,6 +294,163 @@ class DictionaryBuilderBase : public ArrayBuilder {
     return indices_builder_.AppendEmptyValues(length);
   }
 
+  Status AppendScalar(const Scalar& scalar, int64_t n_repeats) override {
+    if (!scalar.type->Equals(type())) {
+      return Status::Invalid("Cannot append scalar of type ", 
scalar.type->ToString(),
+                             " to builder for type ", type()->ToString());
+    }
+    if (!scalar.is_valid) return AppendNulls(n_repeats);
+
+    const auto& dict_ty = internal::checked_cast<const 
DictionaryType&>(*scalar.type);
+    const DictionaryScalar& dict_scalar =
+        internal::checked_cast<const DictionaryScalar&>(scalar);
+    const auto& dict = internal::checked_cast<const typename 
TypeTraits<T>::ArrayType&>(
+        *dict_scalar.value.dictionary);
+    switch (dict_ty.index_type()->id()) {
+      case Type::UINT8: {
+        const auto& value = dict.GetView(
+            internal::checked_cast<const 
UInt8Scalar&>(*dict_scalar.value.index).value);

Review comment:
       Hmm, there should be better testing for nulls in general, I'll amend 
that.




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


Reply via email to