2021-05-17 07:30:42 +00:00
|
|
|
#include <Functions/IFunction.h>
|
2018-09-09 20:57:54 +00:00
|
|
|
#include <Functions/FunctionFactory.h>
|
|
|
|
#include <DataTypes/DataTypeArray.h>
|
|
|
|
#include <DataTypes/DataTypesNumber.h>
|
|
|
|
#include <DataTypes/DataTypeDate.h>
|
|
|
|
#include <DataTypes/DataTypeDateTime.h>
|
2019-11-04 14:06:22 +00:00
|
|
|
#include <DataTypes/DataTypeDateTime64.h>
|
2018-09-09 20:57:54 +00:00
|
|
|
#include <DataTypes/DataTypeString.h>
|
|
|
|
#include <Columns/ColumnArray.h>
|
|
|
|
#include <Columns/ColumnString.h>
|
|
|
|
#include <Columns/ColumnsNumber.h>
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2021-05-04 15:41:58 +00:00
|
|
|
namespace
|
|
|
|
{
|
2018-09-09 20:57:54 +00:00
|
|
|
|
|
|
|
template <typename DataType>
|
2021-05-04 15:41:58 +00:00
|
|
|
class FunctionEmptyArray : public IFunction
|
2018-09-09 20:57:54 +00:00
|
|
|
{
|
2021-05-04 15:41:58 +00:00
|
|
|
public:
|
|
|
|
static String getNameImpl() { return "emptyArray" + DataType().getName(); }
|
2021-06-01 12:20:52 +00:00
|
|
|
static FunctionPtr create(ContextPtr) { return std::make_shared<FunctionEmptyArray>(); }
|
2018-09-09 20:57:54 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
String getName() const override
|
|
|
|
{
|
2021-05-04 15:41:58 +00:00
|
|
|
return getNameImpl();
|
2018-09-09 20:57:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
size_t getNumberOfArguments() const override { return 0; }
|
|
|
|
|
|
|
|
DataTypePtr getReturnTypeImpl(const DataTypes & /*arguments*/) const override
|
|
|
|
{
|
|
|
|
return std::make_shared<DataTypeArray>(std::make_shared<DataType>());
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2020-11-17 13:24:45 +00:00
|
|
|
ColumnPtr executeImpl(const ColumnsWithTypeAndName &, const DataTypePtr &, size_t input_rows_count) const override
|
2018-09-09 20:57:54 +00:00
|
|
|
{
|
2020-10-19 21:21:10 +00:00
|
|
|
return ColumnArray::create(
|
2021-05-04 15:41:58 +00:00
|
|
|
DataType().createColumn(),
|
2018-09-09 20:57:54 +00:00
|
|
|
ColumnArray::ColumnOffsets::create(input_rows_count, 0));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-05-04 15:41:58 +00:00
|
|
|
template <typename F>
|
|
|
|
void registerFunction(FunctionFactory & factory)
|
|
|
|
{
|
|
|
|
factory.registerFunction<F>(F::getNameImpl());
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2018-09-09 20:57:54 +00:00
|
|
|
|
|
|
|
void registerFunctionsEmptyArray(FunctionFactory & factory)
|
|
|
|
{
|
2021-05-05 12:01:01 +00:00
|
|
|
registerFunction<FunctionEmptyArray<DataTypeUInt8>>(factory);
|
|
|
|
registerFunction<FunctionEmptyArray<DataTypeUInt16>>(factory);
|
|
|
|
registerFunction<FunctionEmptyArray<DataTypeUInt32>>(factory);
|
|
|
|
registerFunction<FunctionEmptyArray<DataTypeUInt64>>(factory);
|
|
|
|
registerFunction<FunctionEmptyArray<DataTypeInt8>>(factory);
|
|
|
|
registerFunction<FunctionEmptyArray<DataTypeInt16>>(factory);
|
|
|
|
registerFunction<FunctionEmptyArray<DataTypeInt32>>(factory);
|
|
|
|
registerFunction<FunctionEmptyArray<DataTypeInt64>>(factory);
|
|
|
|
registerFunction<FunctionEmptyArray<DataTypeFloat32>>(factory);
|
|
|
|
registerFunction<FunctionEmptyArray<DataTypeFloat64>>(factory);
|
|
|
|
registerFunction<FunctionEmptyArray<DataTypeDate>>(factory);
|
|
|
|
registerFunction<FunctionEmptyArray<DataTypeDateTime>>(factory);
|
|
|
|
registerFunction<FunctionEmptyArray<DataTypeString>>(factory);
|
2018-09-09 20:57:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|