2017-10-17 10:44:46 +00:00
|
|
|
#pragma once
|
2019-12-09 13:12:54 +00:00
|
|
|
#include <Functions/IFunctionImpl.h>
|
2017-10-17 10:43:42 +00:00
|
|
|
|
2018-11-26 00:56:50 +00:00
|
|
|
namespace DB
|
2017-10-17 10:44:46 +00:00
|
|
|
{
|
|
|
|
|
2019-09-26 10:23:14 +00:00
|
|
|
class ExternalModelsLoader;
|
2020-10-09 07:41:28 +00:00
|
|
|
class Context;
|
2017-10-17 10:43:42 +00:00
|
|
|
|
2017-10-17 12:02:30 +00:00
|
|
|
/// Evaluate external model.
|
|
|
|
/// First argument - model name, the others - model arguments.
|
|
|
|
/// * for CatBoost model - float features first, then categorical
|
|
|
|
/// Result - Float64.
|
2017-10-17 10:43:42 +00:00
|
|
|
class FunctionModelEvaluate final : public IFunction
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static constexpr auto name = "modelEvaluate";
|
|
|
|
|
2017-10-17 10:44:46 +00:00
|
|
|
static FunctionPtr create(const Context & context);
|
2017-10-17 10:43:42 +00:00
|
|
|
|
2019-09-26 10:23:14 +00:00
|
|
|
explicit FunctionModelEvaluate(const ExternalModelsLoader & models_loader_) : models_loader(models_loader_) {}
|
2017-10-17 10:43:42 +00:00
|
|
|
|
|
|
|
String getName() const override { return name; }
|
|
|
|
|
2017-10-17 10:44:46 +00:00
|
|
|
bool isVariadic() const override { return true; }
|
2017-10-17 10:43:42 +00:00
|
|
|
|
2018-08-08 11:26:18 +00:00
|
|
|
bool isDeterministic() const override { return false; }
|
2018-02-21 17:05:21 +00:00
|
|
|
|
2018-12-26 16:44:57 +00:00
|
|
|
bool useDefaultImplementationForNulls() const override { return false; }
|
|
|
|
|
2017-10-17 10:44:46 +00:00
|
|
|
size_t getNumberOfArguments() const override { return 0; }
|
2017-10-17 10:43:42 +00:00
|
|
|
|
2018-12-26 16:44:57 +00:00
|
|
|
DataTypePtr getReturnTypeImpl(const ColumnsWithTypeAndName & arguments) const override;
|
2017-10-17 10:43:42 +00:00
|
|
|
|
2020-10-18 19:00:13 +00:00
|
|
|
ColumnPtr executeImpl(ColumnsWithTypeAndName & arguments, const DataTypePtr & result_type, size_t input_rows_count) const override;
|
2017-10-17 10:43:42 +00:00
|
|
|
|
2017-10-17 10:44:46 +00:00
|
|
|
private:
|
2019-09-26 10:23:14 +00:00
|
|
|
const ExternalModelsLoader & models_loader;
|
2017-10-17 10:43:42 +00:00
|
|
|
};
|
2017-10-17 10:44:46 +00:00
|
|
|
|
|
|
|
}
|