1#include <Functions/IFunctionImpl.h>
2#include <Functions/FunctionFactory.h>
3#include <DataTypes/DataTypeString.h>
4#include <Common/config_version.h>
5#include <Core/Field.h>
6
7
8namespace DB
9{
10
11/** version() - returns the current version as a string.
12 */
13class FunctionVersion : public IFunction
14{
15public:
16 static constexpr auto name = "version";
17 static FunctionPtr create(const Context &)
18 {
19 return std::make_shared<FunctionVersion>();
20 }
21
22 String getName() const override
23 {
24 return name;
25 }
26
27 size_t getNumberOfArguments() const override
28 {
29 return 0;
30 }
31
32 DataTypePtr getReturnTypeImpl(const DataTypes & /*arguments*/) const override
33 {
34 return std::make_shared<DataTypeString>();
35 }
36
37 void executeImpl(Block & block, const ColumnNumbers &, size_t result, size_t input_rows_count) override
38 {
39 block.getByPosition(result).column = DataTypeString().createColumnConst(input_rows_count, VERSION_STRING);
40 }
41};
42
43
44void registerFunctionVersion(FunctionFactory & factory)
45{
46 factory.registerFunction<FunctionVersion>();
47}
48
49}
50