| 48 | exprs_(std::move(exprs)) {} |
| 49 | |
| 50 | static Result<ExecNode*> Make(ExecPlan* plan, std::vector<ExecNode*> inputs, |
| 51 | const ExecNodeOptions& options) { |
| 52 | RETURN_NOT_OK(ValidateExecNodeInputs(plan, inputs, 1, "ProjectNode")); |
| 53 | |
| 54 | const auto& project_options = checked_cast<const ProjectNodeOptions&>(options); |
| 55 | auto exprs = project_options.expressions; |
| 56 | auto names = project_options.names; |
| 57 | |
| 58 | if (names.size() == 0) { |
| 59 | names.resize(exprs.size()); |
| 60 | for (size_t i = 0; i < exprs.size(); ++i) { |
| 61 | names[i] = exprs[i].ToString(); |
| 62 | } |
| 63 | } else { |
| 64 | ARROW_RETURN_IF( |
| 65 | names.size() != exprs.size(), |
| 66 | Status::Invalid("Project node's size of names " + std::to_string(names.size()) + |
| 67 | " doesn't match size of expressions " + |
| 68 | std::to_string(exprs.size()))); |
| 69 | } |
| 70 | FieldVector fields(exprs.size()); |
| 71 | int i = 0; |
| 72 | for (auto& expr : exprs) { |
| 73 | if (!expr.IsBound()) { |
| 74 | ARROW_ASSIGN_OR_RAISE(expr, expr.Bind(*inputs[0]->output_schema(), |
| 75 | plan->query_context()->exec_context())); |
| 76 | } |
| 77 | fields[i] = field(std::move(names[i]), expr.type()->GetSharedPtr()); |
| 78 | ++i; |
| 79 | } |
| 80 | return plan->EmplaceNode<ProjectNode>(plan, std::move(inputs), |
| 81 | schema(std::move(fields)), std::move(exprs)); |
| 82 | } |
| 83 | |
| 84 | const char* kind_name() const override { return "ProjectNode"; } |
| 85 |
nothing calls this directly
no test coverage detected