Converts a field ref into a position-independent ref (containing only a sequence of names) based on the dataset schema. Returns `false` if no conversion was needed.
| 265 | // Converts a field ref into a position-independent ref (containing only a sequence of |
| 266 | // names) based on the dataset schema. Returns `false` if no conversion was needed. |
| 267 | Result<FieldRef> MaybeConvertFieldRef(FieldRef ref, const Schema& dataset_schema) { |
| 268 | if (ARROW_PREDICT_TRUE(ref.IsNameSequence())) { |
| 269 | return ref; |
| 270 | } |
| 271 | |
| 272 | ARROW_ASSIGN_OR_RAISE(auto path, ref.FindOne(dataset_schema)); |
| 273 | std::vector<FieldRef> named_refs; |
| 274 | named_refs.reserve(path.indices().size()); |
| 275 | |
| 276 | const FieldVector* child_fields = &dataset_schema.fields(); |
| 277 | for (auto index : path) { |
| 278 | const auto& child_field = *(*child_fields)[index]; |
| 279 | named_refs.emplace_back(child_field.name()); |
| 280 | child_fields = &child_field.type()->fields(); |
| 281 | } |
| 282 | |
| 283 | return named_refs.size() == 1 ? std::move(named_refs[0]) |
| 284 | : FieldRef(std::move(named_refs)); |
| 285 | } |
| 286 | |
| 287 | // Compute the column projection based on the scan options |
| 288 | Result<std::vector<int>> InferColumnProjection(const parquet::arrow::FileReader& reader, |
no test coverage detected