jorisvandenbossche commented on code in PR #14749:
URL: https://github.com/apache/arrow/pull/14749#discussion_r1035805252
##########
cpp/src/arrow/compute/kernels/scalar_nested.cc:
##########
@@ -131,13 +124,26 @@ struct ListSlice {
list_type->id() == arrow::Type::FIXED_SIZE_LIST);
std::unique_ptr<ArrayBuilder> builder;
+ // should have been checked in resolver
+ // if stop not set, then cannot return fixed size list without input being
fixed size
+ // list b/c we cannot determine the max list element in type resolving.
+ DCHECK(opts.stop.has_value() ||
+ (!opts.stop.has_value() && (!return_fixed_size_list ||
+ list_type->id() ==
arrow::Type::FIXED_SIZE_LIST)));
+
// construct array values
if (return_fixed_size_list) {
- RETURN_NOT_OK(MakeBuilder(
- ctx->memory_pool(),
- fixed_size_list(value_type,
- static_cast<int32_t>(opts.stop.value() -
opts.start)),
- &builder));
+ const auto stop = [&]() {
+ if (opts.stop.has_value()) {
+ return static_cast<int32_t>(opts.stop.value());
+ } else {
+ DCHECK_EQ(list_type->id(), arrow::Type::FIXED_SIZE_LIST);
+ return reinterpret_cast<const
FixedSizeListType*>(list_type)->list_size();
+ }
+ }();
Review Comment:
Code question: is there a reason this is done as a lambda, instead of just a
if/else block? (like you have in the resolver)
--
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]