MCPcopy Create free account
hub / github.com/apache/arrow / NaiveExecuteScalarExpression

Function NaiveExecuteScalarExpression

cpp/src/arrow/compute/expression_test.cc:1100–1128  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1098}
1099
1100Result<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
1130void ExpectExecute(Expression expr, Datum in, Datum* actual_out = NULLPTR) {
1131 std::shared_ptr<Schema> schm;

Callers

nothing calls this directly

Calls 10

CallNotNullFunction · 0.85
literalMethod · 0.80
field_refMethod · 0.80
make_arrayMethod · 0.80
GetTypesFunction · 0.70
ARROW_ASSIGN_OR_RAISEFunction · 0.50
typeMethod · 0.45
sizeMethod · 0.45
ExecuteMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected