ClickHouse/src/Functions/FunctionsStringArray.cpp

43 lines
1.6 KiB
C++
Raw Normal View History

#include <Functions/FunctionFactory.h>
#include <Functions/FunctionsStringArray.h>
2019-12-29 01:13:17 +00:00
namespace DB
{
2021-10-24 11:45:12 +00:00
namespace ErrorCodes
{
extern const int ILLEGAL_TYPE_OF_ARGUMENT;
extern const int NUMBER_OF_ARGUMENTS_DOESNT_MATCH;
}
2021-10-12 21:23:40 +00:00
DataTypePtr FunctionArrayStringConcat::getReturnTypeImpl(const DataTypes & arguments) const
{
if (arguments.size() != 1 && arguments.size() != 2)
throw Exception(
"Number of arguments for function " + getName() + " doesn't match: passed " + toString(arguments.size())
+ ", should be 1 or 2.",
ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH);
const DataTypeArray * array_type = checkAndGetDataType<DataTypeArray>(arguments[0].get());
2021-10-22 20:19:32 +00:00
if (!array_type)
throw Exception("First argument for function " + getName() + " must be an array.", ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);
2021-10-12 21:23:40 +00:00
if (arguments.size() == 2 && !isString(arguments[1]))
throw Exception("Second argument for function " + getName() + " must be constant string.", ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);
return std::make_shared<DataTypeString>();
}
void registerFunctionsStringArray(FunctionFactory & factory)
{
factory.registerFunction<FunctionExtractAll>();
factory.registerFunction<FunctionAlphaTokens>();
factory.registerFunction<FunctionSplitByNonAlpha>();
factory.registerFunction<FunctionSplitByWhitespace>();
factory.registerFunction<FunctionSplitByChar>();
factory.registerFunction<FunctionSplitByString>();
2021-05-13 02:37:09 +00:00
factory.registerFunction<FunctionSplitByRegexp>();
factory.registerFunction<FunctionArrayStringConcat>();
}
}