You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "pitrou (via GitHub)" <gi...@apache.org> on 2023/06/22 11:35:17 UTC

[GitHub] [arrow] pitrou commented on a diff in pull request #36058: GH-36047: [C++][Compute] Add support for duration types to IndexIn and IsIn

pitrou commented on code in PR #36058:
URL: https://github.com/apache/arrow/pull/36058#discussion_r1238401828


##########
cpp/src/arrow/compute/kernels/scalar_set_lookup_test.cc:
##########
@@ -238,6 +239,29 @@ TEST_F(TestIsInKernel, TimeTimestamp) {
             "[true, false, true]");
 }
 
+TEST_F(TestIsInKernel, TimeDuration) {
+  for (const auto& type : DurationTypes()) {
+    CheckIsIn(type, "[1, null, 5, 1, 2]", "[2, 1, null]",
+              "[true, true, false, true, true]", /*skip_nulls=*/false);
+    CheckIsIn(type, "[1, null, 5, 1, 2]", "[2, 1, null]",
+              "[true, false, false, true, true]", /*skip_nulls=*/true);
+
+    // Duplicates in right array
+    CheckIsIn(type, "[1, null, 5, 1, 2]", "[2, 1, 1, null, 2]",
+              "[true, true, false, true, true]", /*skip_nulls=*/false);
+    CheckIsIn(type, "[1, null, 5, 1, 2]", "[2, 1, 1, null, 2]",
+              "[true, false, false, true, true]", /*skip_nulls=*/true);
+  }
+
+  // Different units, invalid cast
+  ASSERT_RAISES(Invalid, IsIn(ArrayFromJSON(duration(TimeUnit::SECOND), "[0, 1, 2]"),
+                              ArrayFromJSON(duration(TimeUnit::MILLI), "[0, 2]")));
+
+  // Different units, valid cast
+  CheckIsIn(ArrayFromJSON(duration(TimeUnit::MILLI), "[0, 1, 2000]"),
+            ArrayFromJSON(duration(TimeUnit::SECOND), "[0, 2]"), "[true, false, true]");

Review Comment:
   What happens if conversion from SECOND to MILLI overflows?



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