dhruv9vats commented on a change in pull request #12162:
URL: https://github.com/apache/arrow/pull/12162#discussion_r785458284
##########
File path: cpp/src/arrow/compute/kernels/scalar_nested_test.cc
##########
@@ -225,6 +225,30 @@ TEST(TestScalarNested, StructField) {
}
}
+TEST(TestScalarNested, MapArrayLookup) {
+ MapArrayLookupOptions foo_all(MakeScalar("foo"), MapArrayLookupOptions::All);
+ MapArrayLookupOptions foo_first(MakeScalar("foo"),
MapArrayLookupOptions::First);
+ auto type = map(utf8(), int32());
+
+ auto keys = ArrayFromJSON(utf8(), R"([
+ "foo", "bar", "hello", "foo", "lesgo", "whatnow",
+ "nothing", "hat", "foo", "sorry", "dip", "foo"
+ ])");
+ auto items = ArrayFromJSON(int16(), R"([
+ 99, 1, 2, 3, 5, 8,
+ null, null, 101, 1, null, 22
+ ])");
+ auto offsets = ArrayFromJSON(int32(), "[0, 6, 6, 12,
12]")->data()->buffers[1];
+ auto null_bitmap = ArrayFromJSON(boolean(), "[1, 0, 1,
1]")->data()->buffers[1];
+
+ MapArray map_array(type, 4, offsets, keys, items, null_bitmap, 1, 0);
+
+ CheckScalarNonRecursive("map_array_lookup", {map_array},
+ ArrayFromJSON(int32(), "[99, 3, 101, 22]"),
&foo_all);
+ CheckScalarNonRecursive("map_array_lookup", {map_array},
ArrayFromJSON(int32(), "[99]"),
Review comment:
Also, this _very_ basic test does (somehow) pass:
<details><summary>Passing test output</summary>
```bash
❯ GTEST_FILTER="TestScalarNested.MapArrayLookup" ctest -R
"arrow-compute-scalar-test" -V
UpdateCTestConfiguration from
:/home/dhruv/repos/arrow/cpp/out/build/ninja-debug/DartConfiguration.tcl
UpdateCTestConfiguration from
:/home/dhruv/repos/arrow/cpp/out/build/ninja-debug/DartConfiguration.tcl
Test project /home/dhruv/repos/arrow/cpp/out/build/ninja-debug
Constructing a list of tests
Done constructing a list of tests
Updating test list for fixtures
Added 0 tests to meet fixture requirements
Checking test dependency graph...
Checking test dependency graph end
test 25
Start 25: arrow-compute-scalar-test
25: Test command: /home/dhruv/repos/arrow/cpp/build-support/run-test.sh
"/home/dhruv/repos/arrow/cpp/out/build/ninja-debug" "test"
"/home/dhruv/repos/arrow/cpp/out/build/ninja-debug/debug//arrow-compute-scalar-test"
25: Test timeout computed to be: 10000000
25: Running arrow-compute-scalar-test, redirecting output into
/home/dhruv/repos/arrow/cpp/out/build/ninja-debug/build/test-logs/arrow-compute-scalar-test.txt
(attempt 1/1)
25: Running main() from ../googletest/src/gtest_main.cc
25: Note: Google Test filter = TestScalarNested.MapArrayLookup
25: [==========] Running 1 test from 1 test suite.
25: [----------] Global test environment set-up.
25: [----------] 1 test from TestScalarNested
25: [ RUN ] TestScalarNested.MapArrayLookup
25: map type found!
25: Value type: int32
25: Key being checked: foo
25: Value at key: 99
25: Item being appended: 99
25: Key being checked: foo
25: Value at key: 3
25: Item being appended: 3
25: Key being checked: foo
25: Value at key: 101
25: Item being appended: 101
25: Key being checked: foo
25: Value at key: 22
25: Item being appended: 22
25: map type found!
25: Value type: int32
25: Key being checked: foo
25: Value at key: 99
25: Item being appended: 99
25: [ OK ] TestScalarNested.MapArrayLookup (10 ms)
25: [----------] 1 test from TestScalarNested (10 ms total)
25:
25: [----------] Global test environment tear-down
25: [==========] 1 test from 1 test suite ran. (10 ms total)
25: [ PASSED ] 1 test.
25: ~/repos/arrow/cpp/out/build/ninja-debug/src/arrow/compute/kernels
1/1 Test #25: arrow-compute-scalar-test ........ Passed 0.08 sec
The following tests passed:
arrow-compute-scalar-test
100% tests passed, 0 tests failed out of 1
Label Time Summary:
arrow_compute = 0.08 sec*proc (1 test)
unittest = 0.08 sec*proc (1 test)
Total Test time (real) = 0.08 sec
```
</details>
(Please do suggest better tests)
--
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]