llama90 commented on code in PR #39192:
URL: https://github.com/apache/arrow/pull/39192#discussion_r1444123716


##########
cpp/src/arrow/scalar.cc:
##########
@@ -884,9 +997,11 @@ std::string Scalar::ToString() const {
     return dict_scalar->value.dictionary->ToString() + "[" +
            dict_scalar->value.index->ToString() + "]";
   }
-  auto maybe_repr = CastTo(utf8());
+
+  auto maybe_repr = Cast(CastToExplicitScalar(), utf8());

Review Comment:
   If explicit conversions to Scalar types are not made, calling a test like 
the one below results in an error due to casting failure.
   
   
https://github.com/apache/arrow/blob/de3130ede1a2db7bbe9e129f21856ee80de0f8cb/cpp/src/arrow/datum_test.cc#L155
   
   The part where an error occurs
   
   
https://github.com/apache/arrow/blob/de3130ede1a2db7bbe9e129f21856ee80de0f8cb/cpp/src/arrow/array/data.cc#L333-L523
   
   For example, in the case of the above unit test, the Scalar type that should 
be passed to the `FillFromScalar` function is `Int8Scalar`. However, if it is 
not explicitly converted, it is passed as a generic `Scalar` type. 
Consequently, when performing a conversion like `const auto& scalar = 
checked_cast<const internal::PrimitiveScalarBase&>(value);`, an error "C++ 
exception with description 'std::bad_cast' thrown in the test body." occurs.
   
   I am curious if there is a better approach. 🤔



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