| 1098 | } |
| 1099 | |
| 1100 | Result<Datum> NaiveExecuteScalarExpression(const Expression& expr, const Datum& input) { |
| 1101 | if (auto lit = expr.literal()) { |
| 1102 | return *lit; |
| 1103 | } |
| 1104 | |
| 1105 | if (auto ref = expr.field_ref()) { |
| 1106 | if (input.type()) { |
| 1107 | return ref->GetOneOrNone(*input.make_array()); |
| 1108 | } |
| 1109 | return ref->GetOneOrNone(*input.record_batch()); |
| 1110 | } |
| 1111 | |
| 1112 | auto call = CallNotNull(expr); |
| 1113 | |
| 1114 | std::vector<Datum> arguments(call->arguments.size()); |
| 1115 | for (size_t i = 0; i < arguments.size(); ++i) { |
| 1116 | ARROW_ASSIGN_OR_RAISE(arguments[i], |
| 1117 | NaiveExecuteScalarExpression(call->arguments[i], input)); |
| 1118 | } |
| 1119 | |
| 1120 | compute::ExecContext exec_context; |
| 1121 | ARROW_ASSIGN_OR_RAISE(auto function, GetFunction(*call, &exec_context)); |
| 1122 | |
| 1123 | std::vector<TypeHolder> types = GetTypes(call->arguments); |
| 1124 | ARROW_ASSIGN_OR_RAISE(auto expected_kernel, function->DispatchExact(types)); |
| 1125 | |
| 1126 | EXPECT_EQ(call->kernel, expected_kernel); |
| 1127 | return function->Execute(arguments, call->options.get(), &exec_context); |
| 1128 | } |
| 1129 | |
| 1130 | void ExpectExecute(Expression expr, Datum in, Datum* actual_out = NULLPTR) { |
| 1131 | std::shared_ptr<Schema> schm; |
nothing calls this directly
no test coverage detected