| 1034 | } |
| 1035 | |
| 1036 | Result<Datum> NaiveExecuteScalarExpression(const Expression& expr, const Datum& input) { |
| 1037 | if (auto lit = expr.literal()) { |
| 1038 | return *lit; |
| 1039 | } |
| 1040 | |
| 1041 | if (auto ref = expr.field_ref()) { |
| 1042 | if (input.type()) { |
| 1043 | return ref->GetOneOrNone(*input.make_array()); |
| 1044 | } |
| 1045 | return ref->GetOneOrNone(*input.record_batch()); |
| 1046 | } |
| 1047 | |
| 1048 | auto call = CallNotNull(expr); |
| 1049 | |
| 1050 | std::vector<Datum> arguments(call->arguments.size()); |
| 1051 | for (size_t i = 0; i < arguments.size(); ++i) { |
| 1052 | ARROW_ASSIGN_OR_RAISE(arguments[i], |
| 1053 | NaiveExecuteScalarExpression(call->arguments[i], input)); |
| 1054 | } |
| 1055 | |
| 1056 | compute::ExecContext exec_context; |
| 1057 | ARROW_ASSIGN_OR_RAISE(auto function, GetFunction(*call, &exec_context)); |
| 1058 | |
| 1059 | std::vector<TypeHolder> types = GetTypes(call->arguments); |
| 1060 | ARROW_ASSIGN_OR_RAISE(auto expected_kernel, function->DispatchExact(types)); |
| 1061 | |
| 1062 | EXPECT_EQ(call->kernel, expected_kernel); |
| 1063 | return function->Execute(arguments, call->options.get(), &exec_context); |
| 1064 | } |
| 1065 | |
| 1066 | void ExpectExecute(Expression expr, Datum in, Datum* actual_out = NULLPTR) { |
| 1067 | std::shared_ptr<Schema> schm; |
nothing calls this directly
no test coverage detected