Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cpp/src/arrow/compute/kernels/vector_nested.cc
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ struct ListParentIndicesArray {
type.ToString());
}

Status Visit(const MapType& type) { return Visit(static_cast<const DataType&>(type)); }

static Result<std::shared_ptr<ArrayData>> Exec(KernelContext* ctx,
const std::shared_ptr<ArrayData>& input,
int64_t base_output_offset = 0) {
Expand Down
12 changes: 12 additions & 0 deletions cpp/src/arrow/compute/kernels/vector_nested_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,18 @@ TEST(TestVectorNested, ListParentIndices) {
}
}

TEST(TestVectorNested, ListParentIndicesMap) {
auto input =
ArrayFromJSON(map(utf8(), uint16()), R"([[["a", 1], ["b", 2]], [["c", 3]]])");
auto chunked =
std::make_shared<ChunkedArray>(ArrayVector{input->Slice(0, 1), input->Slice(1)});
for (const auto& datum : {Datum(input), Datum(chunked)}) {
EXPECT_RAISES_WITH_MESSAGE_THAT(TypeError,
::testing::HasSubstr("expects list input, got map"),
CallFunction("list_parent_indices", {datum}));
}
}

TEST(TestVectorNested, ListParentIndicesChunkedArray) {
const auto types = {
list(int16()),
Expand Down
11 changes: 11 additions & 0 deletions python/pyarrow/tests/test_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -3369,6 +3369,17 @@ def test_list_value_parent_indices(list_type):
assert arr.value_parent_indices().equals(expected)


def test_map_value_parent_indices():
arr = pa.array([{'a': 1, 'b': 2}, {'c': 3}],
type=pa.map_(pa.utf8(), pa.uint16()))

message = "expects list input, got map"
with pytest.raises(pa.ArrowTypeError, match=message):
arr.value_parent_indices()
with pytest.raises(pa.ArrowTypeError, match=message):
pc.list_parent_indices(arr)


@pytest.mark.parametrize(('offset_type', 'list_type'),
[(pa.int32(), pa.list_(pa.int32())),
(pa.int32(), pa.list_(pa.int32(), list_size=2)),
Expand Down
Loading