2021-05-17 07:30:42 +00:00
|
|
|
#include <Functions/IFunction.h>
|
2019-10-12 07:17:30 +00:00
|
|
|
#include <Functions/FunctionFactory.h>
|
|
|
|
#include <DataTypes/DataTypeString.h>
|
2021-10-02 07:13:14 +00:00
|
|
|
#include <base/getFQDNOrHostName.h>
|
2019-10-12 07:17:30 +00:00
|
|
|
#include <Core/Field.h>
|
2019-12-29 01:13:17 +00:00
|
|
|
|
2019-10-12 07:17:30 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
class FunctionFQDN : public IFunction
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static constexpr auto name = "FQDN";
|
2021-06-01 12:20:52 +00:00
|
|
|
static FunctionPtr create(ContextPtr)
|
2019-10-12 07:17:30 +00:00
|
|
|
{
|
|
|
|
return std::make_shared<FunctionFQDN>();
|
|
|
|
}
|
|
|
|
|
|
|
|
String getName() const override
|
|
|
|
{
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isDeterministic() const override { return false; }
|
|
|
|
|
2021-06-22 16:21:23 +00:00
|
|
|
bool isSuitableForShortCircuitArgumentsExecution(const DataTypesWithConstInfo & /*arguments*/) const override { return false; }
|
2021-04-29 14:48:26 +00:00
|
|
|
|
2019-10-12 07:17:30 +00:00
|
|
|
size_t getNumberOfArguments() const override
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
DataTypePtr getReturnTypeImpl(const DataTypes & /*arguments*/) const override
|
|
|
|
{
|
|
|
|
return std::make_shared<DataTypeString>();
|
|
|
|
}
|
|
|
|
|
2020-11-17 13:24:45 +00:00
|
|
|
ColumnPtr executeImpl(const ColumnsWithTypeAndName &, const DataTypePtr & result_type, size_t input_rows_count) const override
|
2019-10-12 07:17:30 +00:00
|
|
|
{
|
2020-10-17 21:41:50 +00:00
|
|
|
return result_type->createColumnConst(
|
2019-10-12 09:21:30 +00:00
|
|
|
input_rows_count, getFQDNOrHostName())->convertToFullColumnIfConst();
|
2019-10-12 07:17:30 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2022-07-04 07:01:39 +00:00
|
|
|
REGISTER_FUNCTION(FQDN)
|
2019-10-12 07:17:30 +00:00
|
|
|
{
|
2022-08-27 20:06:03 +00:00
|
|
|
factory.registerFunction<FunctionFQDN>({}, FunctionFactory::CaseInsensitive);
|
2019-10-12 07:17:30 +00:00
|
|
|
factory.registerFunction<FunctionFQDN>("fullHostName");
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|