| 51 | } |
| 52 | |
| 53 | void apply( |
| 54 | const SelectivityVector& rows, |
| 55 | std::vector<VectorPtr>& args, |
| 56 | const TypePtr& outputType, |
| 57 | exec::EvalCtx& context, |
| 58 | VectorPtr& result) const override { |
| 59 | pybind11::list pyArgs; |
| 60 | if (mapBatch_) { |
| 61 | BOLT_CHECK_EQ(defaultArgs_.size(), 0) |
| 62 | std::shared_ptr<RowVector> rowVector = |
| 63 | bolt::python::combineInputColumns(args, context); |
| 64 | pyArgs.append(pybind11::cast(rowVector)); |
| 65 | } else { |
| 66 | pyArgs = bolt::python::asPyArgs(nArgs_, args, defaultArgs_); |
| 67 | } |
| 68 | |
| 69 | bolt::python::pyTry<void>( |
| 70 | [&]() { result = function_(*pyArgs).cast<VectorPtr>(); }, |
| 71 | [&]() { |
| 72 | return fmt::format( |
| 73 | "Failed to evaluate function '{}' with " |
| 74 | "arguments: '{}'", |
| 75 | bolt::python::pyTypeStr(function_), |
| 76 | bolt::python::toString(pyArgs)); |
| 77 | }); |
| 78 | // `result` will be allocated from the pool of the `pybolt` python |
| 79 | // module. Its lifetime is the same as the one of that module. |
| 80 | if (outputType->isPrimitiveType()) { |
| 81 | BOLT_CHECK_EQ(result->type(), outputType); |
| 82 | } else { |
| 83 | BOLT_CHECK(result->type()->equivalent(*outputType)) |
| 84 | } |
| 85 | } |
| 86 | }; |
| 87 | } // namespace |
| 88 |
nothing calls this directly
no test coverage detected