From d2267495764bb6aedb52884575d92cbb460362c7 Mon Sep 17 00:00:00 2001 From: BayoNet Date: Fri, 15 Nov 2019 16:28:26 +0300 Subject: [PATCH] Added randomASKII function by copying from the currentDatabase Function --- dbms/src/Functions/randomASKII.cpp | 54 +++++++++++++++++++ .../registerFunctionsMiscellaneous.cpp | 2 + 2 files changed, 56 insertions(+) create mode 100644 dbms/src/Functions/randomASKII.cpp diff --git a/dbms/src/Functions/randomASKII.cpp b/dbms/src/Functions/randomASKII.cpp new file mode 100644 index 00000000000..828e1a8028c --- /dev/null +++ b/dbms/src/Functions/randomASKII.cpp @@ -0,0 +1,54 @@ +#include +#include +#include +#include +#include + + +namespace DB +{ + +class FunctionRandomASKII : public IFunction +{ + const String db_name; + +public: + static constexpr auto name = "randomASKII"; + static FunctionPtr create(const Context & context) + { + return std::make_shared(context.getRandomASKII()); + } + + explicit FunctionRandomASKII(const String & db_name_) : db_name{db_name_} + { + } + + String getName() const override + { + return name; + } + size_t getNumberOfArguments() const override + { + return 0; + } + + DataTypePtr getReturnTypeImpl(const DataTypes & /*arguments*/) const override + { + return std::make_shared(); + } + + bool isDeterministic() const override { return false; } + + void executeImpl(Block & block, const ColumnNumbers &, size_t result, size_t input_rows_count) override + { + block.getByPosition(result).column = DataTypeString().createColumnConst(input_rows_count, db_name); + } +}; + + +void registerFunctionRandomASKII(FunctionFactory & factory) +{ + factory.registerFunction(); +} + +} diff --git a/dbms/src/Functions/registerFunctionsMiscellaneous.cpp b/dbms/src/Functions/registerFunctionsMiscellaneous.cpp index 3c0e03e46c3..4c8a5ec84f7 100644 --- a/dbms/src/Functions/registerFunctionsMiscellaneous.cpp +++ b/dbms/src/Functions/registerFunctionsMiscellaneous.cpp @@ -52,6 +52,7 @@ void registerFunctionEvalMLMethod(FunctionFactory &); void registerFunctionBasename(FunctionFactory &); void registerFunctionTransform(FunctionFactory &); void registerFunctionGetMacro(FunctionFactory &); +void registerFunctionRandomASKII(FunctionFactory &); #if USE_ICU void registerFunctionConvertCharset(FunctionFactory &); @@ -106,6 +107,7 @@ void registerFunctionsMiscellaneous(FunctionFactory & factory) registerFunctionBasename(factory); registerFunctionTransform(factory); registerFunctionGetMacro(factory); + registerFunctionRandomASKII(factory); #if USE_ICU registerFunctionConvertCharset(factory);