[
https://issues.apache.org/jira/browse/ARROW-1487?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16276101#comment-16276101
]
ASF GitHub Bot commented on ARROW-1487:
---------------------------------------
wesm commented on a change in pull request #1383: ARROW-1487: [C++] Implement
casts from List<A> to List<B>, where a cast function is defined from any A to B
URL: https://github.com/apache/arrow/pull/1383#discussion_r154537405
##########
File path: cpp/src/arrow/compute/compute-test.cc
##########
@@ -801,6 +801,47 @@ TYPED_TEST(TestDictionaryCast, Basic) {
this->CheckPass(*plain_array, *dict_array, dict_array->type(), options);
}*/
+TEST_F(TestCast, ListToList) {
+ CastOptions options;
+ std::shared_ptr<Array> offsets;
+
+ vector<int32_t> offsets_values = {0, 1, 2, 5, 7, 7, 8, 10};
+ std::vector<bool> offsets_is_valid = {true, true, true, true, false, true,
true, true};
+ ArrayFromVector<Int32Type, int32_t>(offsets_is_valid, offsets_values,
&offsets);
+
+ shared_ptr<Array> int32_plain_array =
+ TestBase::MakeRandomArray<typename TypeTraits<Int32Type>::ArrayType>(10,
2);
+ std::shared_ptr<Array> int32_list_array;
+ ASSERT_OK(
+ ListArray::FromArrays(*offsets, *int32_plain_array, pool_,
&int32_list_array));
+
+ std::shared_ptr<Array> int64_plain_array;
+ ASSERT_OK(Cast(&this->ctx_, *int32_plain_array, int64(), options,
&int64_plain_array));
+ std::shared_ptr<Array> int64_list_array;
+ ASSERT_OK(
+ ListArray::FromArrays(*offsets, *int64_plain_array, pool_,
&int64_list_array));
+
+ std::shared_ptr<Array> float64_plain_array;
+ ASSERT_OK(
+ Cast(&this->ctx_, *int32_plain_array, float64(), options,
&float64_plain_array));
+ std::shared_ptr<Array> float64_list_array;
+ ASSERT_OK(
+ ListArray::FromArrays(*offsets, *float64_plain_array, pool_,
&float64_list_array));
Review comment:
In here, per below, we will want to verify that the casted result retains
zero-copy references to the buffers from the parent array.
There is another nuance to be aware of, which is that the offset member may
be non-zero, so in that case simply reusing the buffers is not the appropriate
action
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> [C++] Implement casts from List<A> to List<B>, where a cast function is
> defined from any A to B
> -----------------------------------------------------------------------------------------------
>
> Key: ARROW-1487
> URL: https://issues.apache.org/jira/browse/ARROW-1487
> Project: Apache Arrow
> Issue Type: New Feature
> Components: C++
> Reporter: Wes McKinney
> Assignee: Licht Takeuchi
> Labels: pull-request-available
> Fix For: 0.9.0
>
>
> If a cast rule for the child type is not implemented, the failure should
> occur during kernel selection rather than at kernel evaluation time.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)