diff --git a/cpp/src/arrow/compute/kernels/scalar_if_else_test.cc b/cpp/src/arrow/compute/kernels/scalar_if_else_test.cc index e007a16d13b..196912679ba 100644 --- a/cpp/src/arrow/compute/kernels/scalar_if_else_test.cc +++ b/cpp/src/arrow/compute/kernels/scalar_if_else_test.cc @@ -3144,6 +3144,14 @@ TEST(TestCoalesce, Boolean) { ArrayFromJSON(type, "[true, true, false, true]")); CheckScalar("coalesce", {scalar1, values1}, ArrayFromJSON(type, "[false, false, false, false]")); + + // Regression test for GH-47234, which was failing due to a MSVC compiler bug + // (possibly https://developercommunity.visualstudio.com/t/10912292 + // or https://developercommunity.visualstudio.com/t/10945478). + auto values_with_null = ArrayFromJSON(type, "[true, false, false, false, false, null]"); + auto expected = ArrayFromJSON(type, "[true, false, false, false, false, true]"); + auto scalar2 = ScalarFromJSON(type, "true"); + CheckScalar("coalesce", {values_with_null, scalar2}, expected); } TEST(TestCoalesce, DayTimeInterval) { diff --git a/python/pyarrow/tests/test_compute.py b/python/pyarrow/tests/test_compute.py index ad61dbc48a7..5441dd493d3 100644 --- a/python/pyarrow/tests/test_compute.py +++ b/python/pyarrow/tests/test_compute.py @@ -1952,6 +1952,28 @@ def test_fill_null_chunked_array(arrow_type): assert result.equals(expected) +def test_fill_null_windows_regression(): + # Regression test for GH-47234, which was failing due to a MSVC compiler bug + # (possibly https://developercommunity.visualstudio.com/t/10912292 + # or https://developercommunity.visualstudio.com/t/10945478) + arr = pa.array([True, False, False, False, False, None]) + s = pa.scalar(True, type=pa.bool_()) + + result = pa.compute.call_function("coalesce", [arr, s]) + result.validate(full=True) + expected = pa.array([True, False, False, False, False, True]) + assert result.equals(expected) + + for ty in [pa.int8(), pa.int16(), pa.int32(), pa.int64()]: + arr = pa.array([1, 2, 3, 4, 5, None], type=ty) + s = pa.scalar(42, type=ty) + + result = pa.compute.call_function("coalesce", [arr, s]) + result.validate(full=True) + expected = pa.array([1, 2, 3, 4, 5, 42], type=ty) + assert result.equals(expected) + + def test_logical(): a = pa.array([True, False, False, None]) b = pa.array([True, True, False, True])