apache / apache/arrow

[C++] Serializing to Substrait does not include all field names if there is a list with structs

Open
#36,792 1 comment 0 reactions 0 assignees View on GitHub
Component: C++ good-second-issue Type: bug
Dominant language
C++
Stars
17.1k
Forks
4.3k
Avg merge
3d 13h
Merged PRs (30d)
88

Description

### Describe the bug, including details regarding any error messages, version, and platform.

Currently field names are figured out using this method:

```
void ToProtoGetDepthFirstNames(const FieldVector& fields,
google::protobuf::RepeatedPtrField* names) {
for (const auto& field : fields) {
*names->Add() = field->name();

if (field->type()->id() == Type::STRUCT) {
ToProtoGetDepthFirstNames(field->type()->fields(), names);
}
}
}
```

If there is a list / large list / map (dictionary? extension?) that has children then their names will not be included in the result.

For example, given the schema:

```
auto schema = arrow::schema(
{arrow::field("preceding_field", arrow::int32()),
arrow::field("points",
arrow::list(arrow::field(
"point", arrow::struct_(
{arrow::field("x", arrow::float64()),
arrow::field("y", arrow::float64())})))),
arrow::field("trailing_field", arrow::int32())});
```

I would expect the names to be `["preceding_field", "points", "x", "y", "trailing_field"]` but I only get `["preceding_field", "points", "trailing_field"]`.

### Component(s)

C++

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.