blob: 989f9dfe8959eb133dba300e0ca1ba84754838ea (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
#pragma once
#include <string>
#include <DataTypes/IDataType.h>
#include <Processors/Sources/ShellCommandSource.h>
#include <Interpreters/IExternalLoadable.h>
namespace DB
{
struct UserDefinedExecutableFunctionArgument
{
DataTypePtr type;
String name;
};
struct UserDefinedExecutableFunctionParameter
{
String name;
DataTypePtr type;
};
struct UserDefinedExecutableFunctionConfiguration
{
std::string name;
std::string command;
std::vector<std::string> command_arguments;
std::vector<UserDefinedExecutableFunctionArgument> arguments;
std::vector<UserDefinedExecutableFunctionParameter> parameters;
DataTypePtr result_type;
String result_name;
};
class UserDefinedExecutableFunction final : public IExternalLoadable
{
public:
UserDefinedExecutableFunction(
const UserDefinedExecutableFunctionConfiguration & configuration_,
std::shared_ptr<ShellCommandSourceCoordinator> coordinator_,
const ExternalLoadableLifetime & lifetime_);
const ExternalLoadableLifetime & getLifetime() const override
{
return lifetime;
}
std::string getLoadableName() const override
{
return configuration.name;
}
bool supportUpdates() const override
{
return true;
}
bool isModified() const override
{
return true;
}
std::shared_ptr<const IExternalLoadable> clone() const override
{
return std::make_shared<UserDefinedExecutableFunction>(configuration, coordinator, lifetime);
}
const UserDefinedExecutableFunctionConfiguration & getConfiguration() const
{
return configuration;
}
std::shared_ptr<ShellCommandSourceCoordinator> getCoordinator() const
{
return coordinator;
}
std::shared_ptr<UserDefinedExecutableFunction> shared_from_this()
{
return std::static_pointer_cast<UserDefinedExecutableFunction>(IExternalLoadable::shared_from_this());
}
std::shared_ptr<const UserDefinedExecutableFunction> shared_from_this() const
{
return std::static_pointer_cast<const UserDefinedExecutableFunction>(IExternalLoadable::shared_from_this());
}
private:
UserDefinedExecutableFunctionConfiguration configuration;
std::shared_ptr<ShellCommandSourceCoordinator> coordinator;
ExternalLoadableLifetime lifetime;
};
}
|