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.
| 282 | // Converts a field ref into a position-independent ref (containing only a sequence of |
| 283 | // names) based on the dataset schema. Returns `false` if no conversion was needed. |
| 284 | Result<FieldRef> MaybeConvertFieldRef(FieldRef ref, const Schema& dataset_schema) { |
| 285 | if (ARROW_PREDICT_TRUE(ref.IsNameSequence())) { |
| 286 | return ref; |
| 287 | } |
| 288 | |
| 289 | ARROW_ASSIGN_OR_RAISE(auto path, ref.FindOne(dataset_schema)); |
| 290 | std::vector<FieldRef> named_refs; |
| 291 | named_refs.reserve(path.indices().size()); |
| 292 | |
| 293 | const FieldVector* child_fields = &dataset_schema.fields(); |
| 294 | for (auto index : path) { |
| 295 | const auto& child_field = *(*child_fields)[index]; |
| 296 | named_refs.emplace_back(child_field.name()); |
| 297 | child_fields = &child_field.type()->fields(); |
| 298 | } |
| 299 | |
| 300 | return named_refs.size() == 1 ? std::move(named_refs[0]) |
| 301 | : FieldRef(std::move(named_refs)); |
| 302 | } |
| 303 | |
| 304 | // Compute the column projection based on the scan options |
| 305 | Result<std::vector<int>> InferColumnProjection(const parquet::arrow::FileReader& reader, |
no test coverage detected