| 96 | namespace { |
| 97 | |
| 98 | Result<DeclarationInfo> ProcessEmitProject( |
| 99 | std::optional<substrait::RelCommon> rel_common_opt, |
| 100 | const DeclarationInfo& project_declr, const std::shared_ptr<Schema>& input_schema) { |
| 101 | if (rel_common_opt) { |
| 102 | switch (rel_common_opt->emit_kind_case()) { |
| 103 | case substrait::RelCommon::EmitKindCase::kDirect: |
| 104 | return project_declr; |
| 105 | case substrait::RelCommon::EmitKindCase::kEmit: { |
| 106 | const auto& emit = rel_common_opt->emit(); |
| 107 | int emit_size = emit.output_mapping_size(); |
| 108 | const auto& proj_options = checked_cast<const acero::ProjectNodeOptions&>( |
| 109 | *project_declr.declaration.options); |
| 110 | FieldVector emit_fields(emit_size); |
| 111 | std::vector<compute::Expression> emit_proj_exprs(emit_size); |
| 112 | for (int i = 0; i < emit_size; i++) { |
| 113 | int32_t map_id = emit.output_mapping(i); |
| 114 | emit_fields[i] = input_schema->field(map_id); |
| 115 | emit_proj_exprs[i] = std::move(proj_options.expressions[map_id]); |
| 116 | } |
| 117 | // Note: DeclarationInfo is created by considering the input to the |
| 118 | // ProjectRel and the ProjectNodeOptions are set by only considering |
| 119 | // what is in the emit expression in Substrait. |
| 120 | return DeclarationInfo{ |
| 121 | acero::Declaration::Sequence( |
| 122 | {std::get<acero::Declaration>(project_declr.declaration.inputs[0]), |
| 123 | {"project", acero::ProjectNodeOptions{std::move(emit_proj_exprs)}}}), |
| 124 | schema(std::move(emit_fields))}; |
| 125 | } |
| 126 | default: |
| 127 | return Status::Invalid("Invalid emit case"); |
| 128 | } |
| 129 | } else { |
| 130 | return project_declr; |
| 131 | } |
| 132 | } |
| 133 | |
| 134 | } // namespace |
| 135 |
no test coverage detected