felipecrv commented on code in PR #42067:
URL: https://github.com/apache/arrow/pull/42067#discussion_r1635560137


##########
cpp/src/arrow/compute/kernels/scalar_nested.cc:
##########
@@ -130,14 +131,56 @@ std::string ToString(const std::optional<T>& o) {
   return o.has_value() ? ToChars(*o) : "(nullopt)";
 }
 
-template <typename Type>
+/// \param stop User-provided stop or the length of the input list
+int64_t ListSliceLength(int64_t start, int64_t step, int64_t stop) {
+  DCHECK_GE(step, 1);
+  const auto size = std::max(stop - start, static_cast<int64_t>(0));
+  return bit_util::CeilDiv(size, step);
+}
+
+std::optional<int64_t> EffectiveSliceStop(const ListSliceOptions& opts,
+                                          const BaseListType& input_type) {
+  if (!opts.stop.has_value() && input_type.id() == Type::FIXED_SIZE_LIST) {
+    return checked_cast<const FixedSizeListType&>(input_type).list_size();
+  }
+  return opts.stop;
+}
+
+Result<TypeHolder> ListSliceOutputType(const ListSliceOptions& opts,
+                                       const BaseListType& input_list_type) {
+  const auto& value_type = input_list_type.field(0);
+  const bool is_fixed_size_list = input_list_type.id() == 
Type::FIXED_SIZE_LIST;
+  const auto return_fixed_size_list =
+      opts.return_fixed_size_list.value_or(is_fixed_size_list);
+  if (return_fixed_size_list) {
+    auto stop = EffectiveSliceStop(opts, input_list_type);
+    if (!stop.has_value()) {
+      return Status::NotImplemented(

Review Comment:
   Right. I just preserved the old behavior, but I will change now.



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