| 809 | } // namespace |
| 810 | |
| 811 | Result<ProjectionDescr> ProjectionDescr::FromStructExpression( |
| 812 | const compute::Expression& projection, const Schema& dataset_schema) { |
| 813 | ARROW_ASSIGN_OR_RAISE(compute::Expression bound_expression, |
| 814 | projection.Bind(dataset_schema)); |
| 815 | |
| 816 | if (bound_expression.type()->id() != Type::STRUCT) { |
| 817 | return Status::Invalid("Projection ", projection.ToString(), |
| 818 | " cannot yield record batches"); |
| 819 | } |
| 820 | std::shared_ptr<Schema> projection_schema = |
| 821 | ::arrow::schema(checked_cast<const StructType&>(*bound_expression.type()).fields(), |
| 822 | dataset_schema.metadata()); |
| 823 | |
| 824 | return ProjectionDescr{std::move(bound_expression), std::move(projection_schema)}; |
| 825 | } |
| 826 | |
| 827 | Result<ProjectionDescr> ProjectionDescr::FromExpressions( |
| 828 | std::vector<compute::Expression> exprs, std::vector<std::string> names, |