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



##########
File path: cpp/src/arrow/compute/kernels/scalar_nested_test.cc
##########
@@ -225,6 +225,56 @@ TEST(TestScalarNested, StructField) {
   }
 }
 
+TEST(TestScalarNested, MapArrayLookupNonRecursive) {
+  MapArrayLookupOptions foo_all(MakeScalar("foo"), MapArrayLookupOptions::ALL);
+  MapArrayLookupOptions foo_first(MakeScalar("foo"), 
MapArrayLookupOptions::FIRST);
+  MapArrayLookupOptions foo_last(MakeScalar("foo"), 
MapArrayLookupOptions::LAST);
+
+  auto type = map(utf8(), int32());
+  const char* input = R"(
+[
+    [["foo", 99], ["bar", 1], ["hello", 2], ["foo", 3], ["lesgo", 5], 
["whatnow", 8]],
+    null,
+    [["nothing", null], ["hat", null], ["foo", 101], ["sorry", 1], ["dip", 
null], ["foo", 22]],
+    []
+  ]
+)";
+  auto map_array = ArrayFromJSON(type, input);
+
+  CheckScalarNonRecursive(
+      "map_array_lookup", {map_array},
+      ArrayFromJSON(list(int32()), "[[99, 3], null, [101, 22], null]"), 
&foo_all);
+  CheckScalarNonRecursive("map_array_lookup", {map_array},
+                          ArrayFromJSON(int32(), "[99, null, 101, null]"), 
&foo_first);
+  CheckScalarNonRecursive("map_array_lookup", {map_array},
+                          ArrayFromJSON(int32(), "[3, null, 22, null]"), 
&foo_last);
+}
+
+TEST(TestScalarNested, MapArrayLookup) {

Review comment:
       But this one fails, 
   
https://github.com/apache/arrow/runs/4853174437?check_suite_focus=true#step:6:5490
   
   <details><summary> with 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 2 tests from 1 test suite.
   25: [----------] Global test environment set-up.
   25: [----------] 2 tests from TestScalarNested
   25: [ RUN      ] TestScalarNested.MapArrayLookupNonRecursive
   25: 
/home/dhruv/repos/arrow/cpp/src/arrow/compute/kernels/scalar_nested.cc:678: 
array[list<item: int32>]
   25: 
/home/dhruv/repos/arrow/cpp/src/arrow/compute/kernels/scalar_nested.cc:675: 
array[int32]
   25: 
/home/dhruv/repos/arrow/cpp/src/arrow/compute/kernels/scalar_nested.cc:675: 
array[int32]
   25: [       OK ] TestScalarNested.MapArrayLookupNonRecursive (31 ms)
   25: [ RUN      ] TestScalarNested.MapArrayLookup
   25: 
/home/dhruv/repos/arrow/cpp/src/arrow/compute/kernels/scalar_nested.cc:678: 
array[list<item: int32>]
   25: 
/home/dhruv/repos/arrow/cpp/src/arrow/compute/kernels/scalar_nested.cc:678: 
scalar[list<item: int32>]
   25: 
/home/dhruv/repos/arrow/cpp/src/arrow/compute/kernels/scalar_nested.cc:593: [
   25:   "foo",
   25:   "bar",
   25:   "hello",
   25:   "foo",
   25:   "lesgo",
   25:   "whatnow"
   25: ]
   25: 
/home/dhruv/repos/arrow/cpp/src/arrow/compute/kernels/scalar_nested.cc:594: [
   25:   99,
   25:   1,
   25:   2,
   25:   3,
   25:   5,
   25:   8
   25: ]
   25: 
/home/dhruv/repos/arrow/cpp/src/arrow/compute/kernels/scalar_nested.cc:595: 
Input: -- is_valid: all not null
   25: -- child 0 type: string
   25:   [
   25:     "foo",
   25:     "bar",
   25:     "hello",
   25:     "foo",
   25:     "lesgo",
   25:     "whatnow"
   25:   ]
   25: -- child 1 type: int32
   25:   [
   25:     99,
   25:     1,
   25:     2,
   25:     3,
   25:     5,
   25:     8
   25:   ]
   25: 
/home/dhruv/repos/arrow/cpp/src/arrow/compute/kernels/scalar_nested.cc:649: 
MapArrayLookup Scalar result: [
   25:   99,
   25:   3
   25: ] Type: list<item: int32>
   25: 
/home/dhruv/repos/arrow/cpp/src/arrow/compute/kernels/scalar_nested.cc:678: 
scalar[list<item: int32>]
   25: unknown file: Failure
   25: C++ exception with description "std::bad_cast" thrown in the test body.
   25: [  FAILED  ] TestScalarNested.MapArrayLookup (3 ms)
   25: [----------] 2 tests from TestScalarNested (35 ms total)
   25:
   25: [----------] Global test environment tear-down
   25: [==========] 2 tests from 1 test suite ran. (35 ms total)
   25: [  PASSED  ] 1 test.
   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.13 sec
   
   0% tests passed, 1 tests failed out of 1
   
   Label Time Summary:
   arrow_compute    =   0.13 sec*proc (1 test)
   unittest         =   0.13 sec*proc (1 test)
   
   Total Test time (real) =   0.13 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>
   
   Am getting this same error as above for every option (`FIRST`, `LAST`, 
`ALL`):
   ```bash
   unknown file: Failure
   C++ exception with description "std::bad_cast" thrown in the test body.
   ```
   and am guessing I'm doing something wrong in `ResolveMapArrayLookupType`




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