milesgranger commented on code in PR #14395:
URL: https://github.com/apache/arrow/pull/14395#discussion_r1010272378


##########
cpp/src/arrow/compute/kernels/scalar_nested.cc:
##########
@@ -87,6 +89,206 @@ Status GetListElementIndex(const ExecValue& value, T* out) {
   return Status::OK();
 }
 
+template <typename Type, typename IndexType>
+struct ListSlice {
+  using offset_type = typename Type::offset_type;
+
+  static Status Exec(KernelContext* ctx, const ExecSpan& batch, ExecResult* 
out) {
+    const auto opts = OptionsWrapper<ListSliceOptions>::Get(ctx);
+
+    // Invariants
+    if (opts.start < 0 || (opts.start >= opts.stop && opts.stop != -1)) {
+      // TODO: support start == stop which should give empty lists
+      return Status::Invalid("`start`(", opts.start,
+                             ") should be greater than 0 and smaller than 
`stop`(",
+                             opts.stop, ")");
+    }
+    if (opts.step != 1) {
+      // TODO: support step in slicing
+      return Status::NotImplemented(
+          "Setting `step` to anything other than 1 is not supported; got 
step=",
+          opts.step);
+    }
+    if (opts.stop == -1) {
+      // TODO: Support slicing to arbitrary end

Review Comment:
   That sounds good! However I can't seem to get around the conversion of the 
options to string in `string_builder` when using the `std::optional<int64_t>`
   
   > /home/milesg/Projects/arrow/cpp/src/arrow/util/string_builder.h:49:10: 
error: no match for 'operator<<' (operand types are 'std::ostream' {aka 
'std::basic_ostream<char>'} and 'const std::optional<long int>')
      49 |   stream << head;
         |   ~~~~~~~^~~~~~~
         
   ---
   
   Edit:
   
   After figuring that out a bit with impl of `operator<<` to write out 
optional, I get:
   > error: no type named 'ArrowType' in 'struct 
arrow::CTypeTraits<std::optional<long int> >
   
   Now sure how far I should chase this one.



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