felipecrv commented on code in PR #35345:
URL: https://github.com/apache/arrow/pull/35345#discussion_r1317973210
##########
cpp/src/arrow/array/builder_base.cc:
##########
@@ -319,10 +324,30 @@ struct DerefConstIterator {
pointer operator->() const { return &(**it); }
};
+/// If A and B are equivalent types, a builder of type A can receive
+/// scalar values of type B and a builder of type B can receive
+/// scalar values of type A.
+///
+/// \param a Type A.
+/// \param b Type B.
+bool AreScalarTypesEquivalent(const DataType& a, const DataType& b) {
+ if (a.Equals(b)) {
+ return true;
+ }
+ if ((a.id() == Type::LIST && b.id() == Type::LIST_VIEW) ||
+ (a.id() == Type::LIST_VIEW && b.id() == Type::LIST) ||
+ (a.id() == Type::LARGE_LIST && b.id() == Type::LARGE_LIST_VIEW) ||
+ (a.id() == Type::LARGE_LIST_VIEW && b.id() == Type::LARGE_LIST)) {
+ return checked_cast<const BaseListType&>(a).value_type()->Equals(
+ *checked_cast<const BaseListType&>(b).value_type());
+ }
+ return false;
+}
+
} // namespace
Status ArrayBuilder::AppendScalar(const Scalar& scalar, int64_t n_repeats) {
- if (!scalar.type->Equals(type())) {
+ if (!AreScalarTypesEquivalent(*scalar.type, *type())) {
Review Comment:
I will remove this and report what fails. If nothing fails, I will simply
remove it, otherwise I will report here what happens.
--
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]