2020-10-09 15:49:14 +00:00
|
|
|
#include <DataTypes/DataTypesNumber.h>
|
|
|
|
#include <Functions/FunctionFactory.h>
|
|
|
|
#include <Functions/FunctionHelpers.h>
|
|
|
|
#include <Functions/IFunctionImpl.h>
|
|
|
|
|
2020-10-10 08:02:04 +00:00
|
|
|
#include <common/getThreadId.h>
|
2020-10-09 15:49:14 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
namespace
|
|
|
|
{
|
|
|
|
class FunctionTid : public IFunction
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static constexpr auto name = "tid";
|
|
|
|
static FunctionPtr create(const Context &) { return std::make_shared<FunctionTid>(); }
|
|
|
|
|
|
|
|
String getName() const override { return name; }
|
|
|
|
|
|
|
|
size_t getNumberOfArguments() const override { return 0; }
|
|
|
|
|
|
|
|
DataTypePtr getReturnTypeImpl(const DataTypes &) const override { return std::make_shared<DataTypeUInt64>(); }
|
|
|
|
|
2020-11-17 13:24:45 +00:00
|
|
|
ColumnPtr executeImpl(const ColumnsWithTypeAndName &, const DataTypePtr &, size_t input_rows_count) const override
|
2020-10-09 15:49:14 +00:00
|
|
|
{
|
2020-10-10 08:02:04 +00:00
|
|
|
auto current_tid = getThreadId();
|
2020-10-19 15:27:41 +00:00
|
|
|
return DataTypeUInt64().createColumnConst(input_rows_count, current_tid);
|
2020-10-09 15:49:14 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void registerFunctionTid(FunctionFactory & factory)
|
|
|
|
{
|
|
|
|
factory.registerFunction<FunctionTid>();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|