js8544 commented on code in PR #36058:
URL: https://github.com/apache/arrow/pull/36058#discussion_r1238469522
##########
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:
It calls Cast with CastOptions::Safe(), so it should return an error.
--
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]