dhruv9vats commented on a change in pull request #12162:
URL: https://github.com/apache/arrow/pull/12162#discussion_r785457583



##########
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},

Review comment:
       Using `CheckScalarNonRecursive` instead of `CheckScalar`, as using the 
latter caused these errors:
   
   <details><summary> Using CheckScalar </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: Item at key: 99
   25: Value being appended: 99
   25: Key being checked: foo
   25: Item at key: 3
   25: Value being appended: 3
   25: Key being checked: foo
   25: Item at key: 101
   25: Value being appended: 101
   25: Key being checked: foo
   25: Item at key: 22
   25: Value being appended: 22
   25: /home/dhruv/repos/arrow/cpp/src/arrow/compute/kernels/test_util.cc:86: 
Failure
   25: Failed
   25: '_error_or_value12.status()' failed with NotImplemented: Function 
'map_array_lookup' has no kernel matching input types (scalar[map<string, 
int32>])
   25: /home/dhruv/repos/arrow/cpp/src/arrow/compute/function.cc:224  
DispatchBest(&inputs)
   25: /home/dhruv/repos/arrow/cpp/src/arrow/compute/kernels/test_util.cc:86: 
Failure
   25: Failed
   25: '_error_or_value12.status()' failed with NotImplemented: Function 
'map_array_lookup' has no kernel matching input types (scalar[map<string, 
int32>])
   25: /home/dhruv/repos/arrow/cpp/src/arrow/compute/function.cc:224  
DispatchBest(&inputs)
   25: /home/dhruv/repos/arrow/cpp/src/arrow/compute/kernels/test_util.cc:86: 
Failure
   25: Failed
   25: '_error_or_value12.status()' failed with NotImplemented: Function 
'map_array_lookup' has no kernel matching input types (scalar[map<string, 
int32>])
   25: /home/dhruv/repos/arrow/cpp/src/arrow/compute/function.cc:224  
DispatchBest(&inputs)
   25: /home/dhruv/repos/arrow/cpp/src/arrow/compute/kernels/test_util.cc:86: 
Failure
   25: Failed
   25: '_error_or_value12.status()' failed with NotImplemented: Function 
'map_array_lookup' has no kernel matching input types (scalar[map<string, 
int32>])
   25: /home/dhruv/repos/arrow/cpp/src/arrow/compute/function.cc:224  
DispatchBest(&inputs)
   25: map type found!
   25: Value type: int32
   25: Key being checked: foo
   25: Item at key: 99
   25: Value being appended: 99
   25: Key being checked: foo
   25: Item at key: 3
   25: Value being appended: 3
   25: /home/dhruv/repos/arrow/cpp/src/arrow/testing/gtest_util.cc:134: Failure
   25: Failed
   25:
   25: @@ -1, +1 @@
   25: +3
   25: Expected:
   25:   [
   25:     99
   25:   ]
   25: Actual:
   25:   [
   25:     99,
   25:     3
   25:   ]
   25: map type found!
   25: Value type: int32
   25: /home/dhruv/repos/arrow/cpp/src/arrow/testing/gtest_util.cc:134: Failure
   25: Failed
   25:
   25: @@ -0, +0 @@
   25: -3
   25: Expected:
   25:   [
   25:     3
   25:   ]
   25: Actual:
   25:   []
   25: map type found!
   25: Value type: int32
   25: Key being checked: foo
   25: Item at key: 99
   25: Value being appended: 99
   25: Key being checked: foo
   25: Item at key: 3
   25: Value being appended: 3
   25: /home/dhruv/repos/arrow/cpp/src/arrow/testing/gtest_util.cc:134: Failure
   25: Failed
   25:
   25: @@ -0, +0 @@
   25: -101
   25: -22
   25: +99
   25: +3
   25: Expected:
   25:   [
   25:     101,
   25:     22
   25:   ]
   25: Actual:
   25:   [
   25:     99,
   25:     3
   25:   ]
   25: map type found!
   25: Value type: int32
   25: map type found!
   25: Value type: int32
   25: Key being checked: foo
   25: Item at key: 99
   25: Value being appended: 99
   25: Key being checked: foo
   25: Item at key: 3
   25: Value being appended: 3
   25: Key being checked: foo
   25: Item at key: 99
   25: Value being appended: 99
   25: Key being checked: foo
   25: Item at key: 3
   25: Value being appended: 3
   25: /home/dhruv/repos/arrow/cpp/src/arrow/testing/gtest_util.cc:223: Failure
   25: Failed
   25: Got:
   25:   [
   25:     [
   25:       99,
   25:       3
   25:     ],
   25:     [
   25:       99,
   25:       3
   25:     ]
   25:   ]
   25: Expected:
   25:   [
   25:     [
   25:       99
   25:     ],
   25:     [
   25:       3,
   25:       101,
   25:       22
   25:     ]
   25:   ]
   25: map type found!
   25: Value type: int32
   25: Key being checked: foo
   25: Item at key: 99
   25: Value being appended: 99
   25: /home/dhruv/repos/arrow/cpp/src/arrow/compute/kernels/test_util.cc:119: 
Failure
   25: Expected equality of these values:
   25:   input.array()->length
   25:     Which is: 4
   25:   expected->length()
   25:     Which is: 1
   25: [  FAILED  ] TestScalarNested.MapArrayLookup (9 ms)
   25: [----------] 1 test from TestScalarNested (9 ms total)
   25:
   25: [----------] Global test environment tear-down
   25: [==========] 1 test from 1 test suite ran. (9 ms total)
   25: [  PASSED  ] 0 tests.
   25: [  FAILED  ] 1 test, listed below:
   25: [  FAILED  ] TestScalarNested.MapArrayLookup
   25:
   25:  1 FAILED TEST
   25: ~/repos/arrow/cpp/out/build/ninja-debug/src/arrow/compute/kernels
   1/1 Test #25: arrow-compute-scalar-test ........***Failed    0.08 sec
   
   0% tests passed, 1 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
   
   The following tests FAILED:
            25 - arrow-compute-scalar-test (Failed)
   Errors while running CTest
   Output from these tests are in: 
/home/dhruv/repos/arrow/cpp/out/build/ninja-debug/Testing/Temporary/LastTest.log
   Use "--rerun-failed --output-on-failure" to re-run the failed cases 
verbosely.
   ```
   
   </details>
   
   Also, what would a kernel that takes `Type::MAP` of shape 
`ValueDescr::SCALAR`, that is, a Scalar kernel, look like here?
   




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


Reply via email to