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