| 182 | } |
| 183 | |
| 184 | Result<std::unique_ptr<substrait::ExtendedExpression>> ToProto( |
| 185 | const BoundExpressions& bound_expressions, ExtensionSet* ext_set, |
| 186 | const ConversionOptions& conversion_options) { |
| 187 | auto expression = std::make_unique<substrait::ExtendedExpression>(); |
| 188 | expression->set_allocated_version(CreateVersion().release()); |
| 189 | ARROW_ASSIGN_OR_RAISE(std::unique_ptr<substrait::NamedStruct> base_schema, |
| 190 | ToProto(*bound_expressions.schema, ext_set, conversion_options)); |
| 191 | expression->set_allocated_base_schema(base_schema.release()); |
| 192 | for (const auto& named_expression : bound_expressions.named_expressions) { |
| 193 | Expression bound_expr = named_expression.expression; |
| 194 | if (!bound_expr.IsBound()) { |
| 195 | // This will use the default function registry. Most of the time that will be fine. |
| 196 | // In the cases where this is not what the user wants then the user should make sure |
| 197 | // to pass in bound expressions. |
| 198 | ARROW_ASSIGN_OR_RAISE(bound_expr, bound_expr.Bind(*bound_expressions.schema)); |
| 199 | } |
| 200 | ARROW_ASSIGN_OR_RAISE(std::unique_ptr<substrait::ExpressionReference> expr_ref, |
| 201 | CreateExpressionReference(named_expression.name, bound_expr, |
| 202 | ext_set, conversion_options)); |
| 203 | expression->mutable_referred_expr()->AddAllocated(expr_ref.release()); |
| 204 | } |
| 205 | RETURN_NOT_OK(AddExtensionSetToExtendedExpression(*ext_set, expression.get())); |
| 206 | return expression; |
| 207 | } |
| 208 | |
| 209 | } // namespace engine |
| 210 | } // namespace arrow |
no test coverage detected