| 1080 | } |
| 1081 | |
| 1082 | Result<std::unique_ptr<substrait::FilterRel>> FilterRelationConverter( |
| 1083 | const std::shared_ptr<Schema>& schema, const acero::Declaration& declaration, |
| 1084 | ExtensionSet* ext_set, const ConversionOptions& conversion_options) { |
| 1085 | auto filter_rel = std::make_unique<substrait::FilterRel>(); |
| 1086 | const auto& filter_node_options = |
| 1087 | checked_cast<const acero::FilterNodeOptions&>(*(declaration.options)); |
| 1088 | |
| 1089 | auto filter_expr = filter_node_options.filter_expression; |
| 1090 | compute::Expression bound_expression; |
| 1091 | if (!filter_expr.IsBound()) { |
| 1092 | ARROW_ASSIGN_OR_RAISE(bound_expression, filter_expr.Bind(*schema)); |
| 1093 | } |
| 1094 | |
| 1095 | if (declaration.inputs.size() == 0) { |
| 1096 | return Status::Invalid("Filter node doesn't have an input."); |
| 1097 | } |
| 1098 | |
| 1099 | // handling input |
| 1100 | auto declr_input = declaration.inputs[0]; |
| 1101 | ARROW_ASSIGN_OR_RAISE(auto input_rel, ToProto(std::get<acero::Declaration>(declr_input), |
| 1102 | ext_set, conversion_options)); |
| 1103 | filter_rel->set_allocated_input(input_rel.release()); |
| 1104 | |
| 1105 | ARROW_ASSIGN_OR_RAISE(auto subs_expr, |
| 1106 | ToProto(bound_expression, ext_set, conversion_options)); |
| 1107 | filter_rel->set_allocated_condition(subs_expr.release()); |
| 1108 | return filter_rel; |
| 1109 | } |
| 1110 | |
| 1111 | Status SerializeAndCombineRelations(const acero::Declaration& declaration, |
| 1112 | ExtensionSet* ext_set, |