wesm commented on code in PR #13364:
URL: https://github.com/apache/arrow/pull/13364#discussion_r897351596


##########
python/pyarrow/tests/test_compute.py:
##########
@@ -729,31 +729,6 @@ def test_generated_docstrings():
         memory_pool : pyarrow.MemoryPool, optional
             If not passed, will allocate memory from the default memory pool.
         """)
-    # Nullary with options
-    assert pc.random.__doc__ == textwrap.dedent("""\

Review Comment:
   This function wrapper isn't auto-generated -- maybe it could be but I 
couldn't figure out how to make it work in the 10 or so minutes I spent on it



##########
cpp/src/arrow/compute/kernels/scalar_arithmetic.cc:
##########
@@ -1416,63 +1416,30 @@ std::shared_ptr<ScalarFunction> 
MakeUnaryArithmeticFunctionNotNull(std::string n
   return func;
 }
 
+#define ROUND_CASE(MODE)                                                       
\
+  case RoundMode::MODE: {                                                      
\
+    using Op = OpImpl<Type, RoundMode::MODE>;                                  
\
+    return ScalarUnaryNotNullStateful<Type, Type, Op>(Op(state, *out->type())) 
\
+        .Exec(ctx, batch, out);                                                
\
+  }
+
 // Exec the round kernel for the given types
 template <typename Type, typename OptionsType,
           template <typename, RoundMode, typename...> class OpImpl>
-Status ExecRound(KernelContext* ctx, const ExecBatch& batch, Datum* out) {
+Status ExecRound(KernelContext* ctx, const ExecSpan& batch, ExecResult* out) {
   using State = RoundOptionsWrapper<OptionsType>;
   const auto& state = static_cast<const State&>(*ctx->state());
   switch (state.options.round_mode) {
-    case RoundMode::DOWN: {
-      using Op = OpImpl<Type, RoundMode::DOWN>;
-      return ScalarUnaryNotNullStateful<Type, Type, Op>(Op(state, 
*out->type()))
-          .Exec(ctx, batch, out);
-    }
-    case RoundMode::UP: {
-      using Op = OpImpl<Type, RoundMode::UP>;
-      return ScalarUnaryNotNullStateful<Type, Type, Op>(Op(state, 
*out->type()))
-          .Exec(ctx, batch, out);
-    }
-    case RoundMode::TOWARDS_ZERO: {
-      using Op = OpImpl<Type, RoundMode::TOWARDS_ZERO>;
-      return ScalarUnaryNotNullStateful<Type, Type, Op>(Op(state, 
*out->type()))
-          .Exec(ctx, batch, out);
-    }
-    case RoundMode::TOWARDS_INFINITY: {
-      using Op = OpImpl<Type, RoundMode::TOWARDS_INFINITY>;
-      return ScalarUnaryNotNullStateful<Type, Type, Op>(Op(state, 
*out->type()))
-          .Exec(ctx, batch, out);
-    }
-    case RoundMode::HALF_DOWN: {
-      using Op = OpImpl<Type, RoundMode::HALF_DOWN>;
-      return ScalarUnaryNotNullStateful<Type, Type, Op>(Op(state, 
*out->type()))
-          .Exec(ctx, batch, out);
-    }
-    case RoundMode::HALF_UP: {
-      using Op = OpImpl<Type, RoundMode::HALF_UP>;
-      return ScalarUnaryNotNullStateful<Type, Type, Op>(Op(state, 
*out->type()))
-          .Exec(ctx, batch, out);
-    }
-    case RoundMode::HALF_TOWARDS_ZERO: {
-      using Op = OpImpl<Type, RoundMode::HALF_TOWARDS_ZERO>;
-      return ScalarUnaryNotNullStateful<Type, Type, Op>(Op(state, 
*out->type()))
-          .Exec(ctx, batch, out);
-    }
-    case RoundMode::HALF_TOWARDS_INFINITY: {
-      using Op = OpImpl<Type, RoundMode::HALF_TOWARDS_INFINITY>;
-      return ScalarUnaryNotNullStateful<Type, Type, Op>(Op(state, 
*out->type()))
-          .Exec(ctx, batch, out);
-    }
-    case RoundMode::HALF_TO_EVEN: {
-      using Op = OpImpl<Type, RoundMode::HALF_TO_EVEN>;
-      return ScalarUnaryNotNullStateful<Type, Type, Op>(Op(state, 
*out->type()))
-          .Exec(ctx, batch, out);
-    }
-    case RoundMode::HALF_TO_ODD: {
-      using Op = OpImpl<Type, RoundMode::HALF_TO_ODD>;
-      return ScalarUnaryNotNullStateful<Type, Type, Op>(Op(state, 
*out->type()))
-          .Exec(ctx, batch, out);
-    }
+    ROUND_CASE(DOWN)
+    ROUND_CASE(UP)
+    ROUND_CASE(TOWARDS_ZERO)
+    ROUND_CASE(TOWARDS_INFINITY)
+    ROUND_CASE(HALF_DOWN)
+    ROUND_CASE(HALF_UP)
+    ROUND_CASE(HALF_TOWARDS_ZERO)
+    ROUND_CASE(HALF_TOWARDS_INFINITY)
+    ROUND_CASE(HALF_TO_EVEN)
+    ROUND_CASE(HALF_TO_ODD)

Review Comment:
   will do



-- 
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: github-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to