rok commented on a change in pull request #12139:
URL: https://github.com/apache/arrow/pull/12139#discussion_r795717545



##########
File path: cpp/src/arrow/compute/kernels/scalar_arithmetic.cc
##########
@@ -2090,6 +2146,34 @@ std::shared_ptr<ScalarFunction> 
MakeArithmeticFunctionFloatingPointNotNull(
   return func;
 }
 
+template <template <bool, int64_t> class Op>
+void AddArithmeticFunctionTimeDurations(std::shared_ptr<ScalarFunction> func) {
+  // Add subtract(time32, duration) -> time32
+  TimeUnit::type unit = TimeUnit::SECOND;
+  auto exec_1 = ScalarBinary<Time32Type, Time32Type, DurationType, Op<true, 
86400>>::Exec;
+  DCHECK_OK(func->AddKernel({match::Time32TypeUnit(unit), duration(unit)},
+                            OutputType(FirstType), std::move(exec_1)));
+
+  unit = TimeUnit::MILLI;
+  auto exec_2 =
+      ScalarBinary<Time32Type, Time32Type, DurationType, Op<true, 
86400000>>::Exec;
+  DCHECK_OK(func->AddKernel({match::Time32TypeUnit(unit), duration(unit)},
+                            OutputType(FirstType), std::move(exec_2)));
+
+  // Add subtract(time64, duration) -> time64
+  unit = TimeUnit::MICRO;
+  auto exec_3 =
+      ScalarBinary<Time64Type, Time64Type, DurationType, Op<false, 
86400000000>>::Exec;
+  DCHECK_OK(func->AddKernel({match::Time64TypeUnit(unit), duration(unit)},
+                            OutputType(FirstType), std::move(exec_3)));
+
+  unit = TimeUnit::NANO;
+  auto exec_4 =
+      ScalarBinary<Time64Type, Time64Type, DurationType, Op<false, 
86400000000000>>::Exec;
+  DCHECK_OK(func->AddKernel({match::Time64TypeUnit(unit), duration(unit)},
+                            OutputType(FirstType), std::move(exec_4)));

Review comment:
       Good point!




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