js8544 commented on code in PR #36204:
URL: https://github.com/apache/arrow/pull/36204#discussion_r1245037561
##########
cpp/src/arrow/compute/kernels/scalar_set_lookup_test.cc:
##########
@@ -779,11 +794,11 @@ TEST_F(TestIndexInKernel, TimeDuration) {
CheckIndexIn(duration(TimeUnit::SECOND), "[null, null, null, null]",
"[null]",
"[0, 0, 0, 0]");
- // Different units, invalid cast
- ASSERT_RAISES(Invalid, IndexIn(ArrayFromJSON(duration(TimeUnit::SECOND),
"[0, 1, 2]"),
- ArrayFromJSON(duration(TimeUnit::MILLI), "[0,
2]")));
+ // Different units, cast value_set to values
Review Comment:
Done
##########
cpp/src/arrow/compute/kernels/scalar_set_lookup_test.cc:
##########
@@ -822,6 +837,50 @@ TEST_F(TestIndexInKernel, Boolean) {
CheckIndexIn(boolean(), "[null, null, null, null]", "[null]", "[0, 0, 0,
0]");
}
+TEST_F(TestIndexInKernel, ImplicitlyCastValueSet) {
+ auto input = ArrayFromJSON(int8(), "[0, 1, 2, 3, 4, 5, 6, 7, 8]");
+
+ SetLookupOptions opts{ArrayFromJSON(int32(), "[2, 3, 5, 7]")};
+ ASSERT_OK_AND_ASSIGN(Datum out, CallFunction("index_in", {input}, &opts));
+
+ auto expected = ArrayFromJSON(int32(), ("[null, null, 0, 1, null,"
+ "2, null, 3, null]"));
+ AssertArraysEqual(*expected, *out.make_array());
+
+ // Although value_set cannot be cast to int8, but int8 is castable to float
+ CheckIndexIn(input, ArrayFromJSON(float32(), "[1.0, 2.5, 3.1, 5.0]"),
+ "[null, 0, null, null, null, 3, null, null, null]");
+
+ // Allow implicit casts between binary types...
+ CheckIndexIn(ArrayFromJSON(binary(), R"(["aaa", "bbb", "ccc", null,
"bbb"])"),
Review Comment:
Done
--
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]