pitrou commented on a change in pull request #12105:
URL: https://github.com/apache/arrow/pull/12105#discussion_r786724844



##########
File path: cpp/src/arrow/compute/kernels/scalar_arithmetic.cc
##########
@@ -2428,6 +2435,20 @@ void RegisterScalarArithmetic(FunctionRegistry* 
registry) {
     DCHECK_OK(subtract->AddKernel({in_type, in_type}, duration(unit), 
std::move(exec)));
   }
 
+  // Add subtract(time32, time32) -> duration
+  for (auto unit : {TimeUnit::SECOND, TimeUnit::MILLI}) {
+    InputType in_type(match::Time32TypeUnit(unit));
+    auto exec = ScalarBinaryEqualTypes<Int64Type, Time32Type, 
SubtractTime32>::Exec;

Review comment:
       I'm curious, why doesn't this simply work with `Subtract` as below?

##########
File path: cpp/src/arrow/compute/kernels/scalar_arithmetic.cc
##########
@@ -2428,6 +2435,20 @@ void RegisterScalarArithmetic(FunctionRegistry* 
registry) {
     DCHECK_OK(subtract->AddKernel({in_type, in_type}, duration(unit), 
std::move(exec)));
   }
 
+  // Add subtract(time32, time32) -> duration
+  for (auto unit : {TimeUnit::SECOND, TimeUnit::MILLI}) {
+    InputType in_type(match::Time32TypeUnit(unit));
+    auto exec = ScalarBinaryEqualTypes<Int64Type, Time32Type, 
SubtractTime32>::Exec;
+    DCHECK_OK(subtract->AddKernel({in_type, in_type}, duration(unit), 
std::move(exec)));
+  }
+
+  // Add subtract(time64, time64) -> duration
+  for (auto unit : {TimeUnit::MICRO, TimeUnit::NANO}) {
+    InputType in_type(match::Time64TypeUnit(unit));
+    auto exec = ScalarBinaryEqualTypes<Int64Type, Time64Type, Subtract>::Exec;
+    DCHECK_OK(subtract->AddKernel({in_type, in_type}, duration(unit), 
std::move(exec)));
+  }
+
   DCHECK_OK(registry->AddFunction(std::move(subtract)));
 
   // ----------------------------------------------------------------------

Review comment:
       Shouldn't we add a "subtract_checked" kernel as well below?




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