2017-10-17 10:44:46 +00:00
|
|
|
#pragma once
|
|
|
|
#include <Functions/IFunction.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
|
|
|
{
|
|
|
|
|
|
|
|
class ExternalModels;
|
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
|
|
|
|
2017-10-17 10:44:46 +00:00
|
|
|
explicit FunctionModelEvaluate(const ExternalModels & models) : models(models) {}
|
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
|
|
|
|
2018-04-24 07:16:39 +00:00
|
|
|
void executeImpl(Block & block, const ColumnNumbers & arguments, size_t result, size_t input_rows_count) override;
|
2017-10-17 10:43:42 +00:00
|
|
|
|
2017-10-17 10:44:46 +00:00
|
|
|
private:
|
|
|
|
const ExternalModels & models;
|
2017-10-17 10:43:42 +00:00
|
|
|
};
|
2017-10-17 10:44:46 +00:00
|
|
|
|
|
|
|
}
|