| 1 | #pragma once |
| 2 | #include <Functions/IFunctionImpl.h> |
| 3 | |
| 4 | namespace DB |
| 5 | { |
| 6 | |
| 7 | class ExternalModelsLoader; |
| 8 | |
| 9 | /// Evaluate external model. |
| 10 | /// First argument - model name, the others - model arguments. |
| 11 | /// * for CatBoost model - float features first, then categorical |
| 12 | /// Result - Float64. |
| 13 | class FunctionModelEvaluate final : public IFunction |
| 14 | { |
| 15 | public: |
| 16 | static constexpr auto name = "modelEvaluate" ; |
| 17 | |
| 18 | static FunctionPtr create(const Context & context); |
| 19 | |
| 20 | explicit FunctionModelEvaluate(const ExternalModelsLoader & models_loader_) : models_loader(models_loader_) {} |
| 21 | |
| 22 | String getName() const override { return name; } |
| 23 | |
| 24 | bool isVariadic() const override { return true; } |
| 25 | |
| 26 | bool isDeterministic() const override { return false; } |
| 27 | |
| 28 | bool useDefaultImplementationForNulls() const override { return false; } |
| 29 | |
| 30 | size_t getNumberOfArguments() const override { return 0; } |
| 31 | |
| 32 | DataTypePtr getReturnTypeImpl(const ColumnsWithTypeAndName & arguments) const override; |
| 33 | |
| 34 | void executeImpl(Block & block, const ColumnNumbers & arguments, size_t result, size_t input_rows_count) override; |
| 35 | |
| 36 | private: |
| 37 | const ExternalModelsLoader & models_loader; |
| 38 | }; |
| 39 | |
| 40 | } |
| 41 | |