You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/02/16 00:01:00 UTC

[GitHub] [arrow] rok commented on a change in pull request #12141: ARROW-14100: [C++] subtract(duration, duration) -> duration kernel

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



##########
File path: cpp/src/arrow/compute/kernels/scalar_temporal_test.cc
##########
@@ -1242,6 +1242,21 @@ TEST_F(ScalarTemporalTest, TestTemporalSubtractTimeAndDuration) {
   }
 }
 
+TEST_F(ScalarTemporalTest, TestTemporalSubtractDuration) {
+  for (auto op : {"subtract", "subtract_checked"}) {
+    for (auto u : TimeUnit::values()) {
+      auto unit = duration(u);
+      CheckScalarBinary(op, ArrayFromJSON(unit, times_s2), ArrayFromJSON(unit, times_s),
+                        ArrayFromJSON(unit, seconds_between_time));
+    }
+
+    auto seconds_3 = ArrayFromJSON(duration(TimeUnit::SECOND), R"([3, null])");
+    auto milliseconds_2k = ArrayFromJSON(duration(TimeUnit::MILLI), R"([2000, null])");
+    auto milliseconds_1k = ArrayFromJSON(duration(TimeUnit::MILLI), R"([1000, null])");
+    CheckScalarBinary(op, seconds_3, milliseconds_2k, milliseconds_1k);
+  }
+}

Review comment:
       Added. However it seems as it duration is not treated as `int64_t` [here](https://github.com/apache/arrow/blob/master/cpp/src/arrow/util/int_util_internal.h#L59) and overflow is not detected?




-- 
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-unsubscribe@arrow.apache.org

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